Create a Link Ad for a Facebook object (event url) - facebook

In business manager it's possible to create a Link Ad with a Facebook Event url. I like to do the same with Facebook Ads API but facing a permissions error.
The Ad Creative of an Ad created in business manager looks like this one:
{
"object_story_spec": {
"page_id": "24188824589????",
"link_data": {
"link": "https://www.facebook.com/events/25595316793????/",
"message": "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
"image_hash": "cbb1f226fd5fe47c826dd1cad117????"
}
}
}
When I am trying to create the same Ad Creative via Ads Api I get an error message like the following:
{
"error": {
"message": "Invalid parameter",
"type": "FacebookApiException",
"code": 100,
"error_subcode": 1349118,
"is_transient": false,
"error_user_title": "Disallowed Post Link",
"error_user_msg": "One or more of the given URLs is not allowed by the Stream post URL security app setting. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains. Read https://developers.facebook.com/docs/facebook-login/security/ to learn more about app settings related to security."
}
}
I get the same error if I try to create a Link Post with Graph API separately to use as object_story_id.
We really need this kind of Ads for our business. In stream ads perform much better than display ads. Is there anyway to create ads like this one via Ads API?

You should check the migration settings for your app to see if "Steam post URL security" is enabled.
This prevents URLs being posted by your app which do not link to a domain listed in your app settings.

Related

Facebook Marketing API - Creating an Ad in development mode

I'm implementing an application using Facebook Marketing API's SDK (python), I'm a newbie to this, yet I read the documentation and I was able to create campaigns, and ad sets. But not for ad creatives. The error was that my app is in dev mode and I need to switch it to be public.
Status: 400
Response:
{
"error": {
"message": "Invalid parameter",
"type": "OAuthException",
"code": 100,
"error_subcode": 1885183,
"is_transient": false,
"error_user_title": "Ads creative post was created by an app that is in development mode",
"error_user_msg": "Ads creative post was created by an app that is in development mode. It must be in public to create this ad.",
"fbtrace_id": "Dxgr83ugqSu"
}
}
Once I did, another error occurred stating that an extended permission should be granted:
Status: 403
Response:
{
“error”: {
“message”: “(#294) Managing advertisements requires an access token with the extended permission for ads_management”,
“type”: “OAuthException”,
“code”: 294,
“fbtrace_id”: “HZ8N55VciZg”
}
}
What I did understand is that I need to submit my app for review before trying to push the ad. However, I was wondering if it is possible by anyway to push an ad without doing so? for the sake of testing my script?
Note: it is the same case for sandbox mode.
apologize if this sound like a naive question.

Facebook API: Instagram Account Is Missing

whenever creating or updating an Ad's creative, I'm getting this error:
{
"error": {
"message": "Invalid parameter",
"type": "OAuthException",
"code": 100,
"error_subcode": 1772103,
"is_transient": false,
"error_user_title": "Instagram Account Is Missing",
"error_user_msg": "You're using Instagram as a placement. Please select an Instagram account to represent your business in your Instagram ads, or select a Facebook Page to use instead.",
"fbtrace_id": "..."
}
}
However, what I simply try to do is to create an Ad for a specifc Page Post and add this to an existing AdSet. To create a new creative for a given Post, I use the /adcreatives endpoint and pass the following:
POST: https://graph.facebook.com/v3.1/act_<ActId>/adcreatives
{
"name": "Test",
"object_story_id":"<PostIdWithPage>",
}
This works fine so far. But the following update of the Ad results in the error above:
POST: https://graph.facebook.com/v3.1/<AdId>
{
"creative": {
"creative_id": "<CreativeId>",
}
}
I guess, the above error happens when I try to add a creative to the Ad that can not be used on Instagram.
But why isn't it working like in the Business Manager? There, I can simply select a Post for a newly created Ad. If this Post is not valid for Instagram, it shows a warning but it still works.
So, when I want to create a tool that can create Ads based on given Posts, how can I achieve that? How can we come around the error above?
The important missing part here is, that we have to specify instagram_actor_id when creating the AdCreative. The ID can be retrieved by GETting <PageId>/page_backed_instagram_accounts.
Further to the accepted answer, I needed a little bit more information to properly connect an instagram account to my page:
There are two ways to link in instagram account to your page:
1. Setup a 'Page Connected' instagram account
Log in as a page admin, go to page settings > instagram and link
an existing instagram account to the page.
You can then get the linked instagram account id by doing a GET on:
<PageId>/instagram_accounts
2. Create a 'Page Backed' instagram account.
This is for when you don't have an existing instagram account you want to link to your page, and want to instead create a 'shadow' instagram account based off your page.
You can generate a paged backed instagram account by performing a POST on the following endpoint. And retrieve an existing one, by performing a GET.
<PageId>/page_backed_instagram_accounts
** Note that both these endpoints require you to have a 'page access token' rather than the normal 'account access token' you use to create your ads.
To get your page access token, you can do a GET request on:
/me/accounts
Then, as stated in the accepted answer - pass your new, linked instagram account id as the instagram_actor_id in your ad creative request.
Sources:
https://developers.facebook.com/docs/marketing-api/guides/instagramads/
https://developers.facebook.com/docs/facebook-login/access-tokens#pagetokens

facebook ads api - read other account campaigns

I am using Facebook ads api to read campaign from other account. I have created the application, got app_id and app_secret. In graph explorer, I am using other person's access token and account id to get his campaigns. But facebook gives me following error:
{
"error": {
"message": "(#274) The ad account is not enabled for usage in Ads API. Please add it in developers.facebook.com/apps -> select your app -> settings -> advanced -> advertising accounts -> Ads API. Account 1817273581872129 not enabled for this application.",
"type": "OAuthException",
"code": 274,
"fbtrace_id": "GW38TMsIi1v"
}
}
I did followed error instructions but still the same problem.
here is the url i am using in graph explorer:
act_12345566654/campaigns
However, when I use facebook ads api in python:
I get the following error:
FacebookRequestError:
Message: Call was not successful
Method: GET
Path: https://graph.facebook.com/v2.8/act_1817273581872129/campaigns
Params: {'summary': 'true'}
Status: 400
Response:
{
"error": {
"message": "Invalid appsecret_proof provided in the API argument",
"code": 100,
"type": "GraphMethodException",
"fbtrace_id": "FRdlngO8f04"
}
}
Here is the code:
session = FacebookSession(self.app_id, self.app_secret, self.access_token)
ads_api = FacebookAdsApi(session)
adaccount = AdAccount(self.account_id, api=ads_api)
campaigns = adaccount.get_campaigns()
Where am I going wrong ? Kindly assist me
Most likely, the app secret that you have provided doesn't belong to the app id or the access token that you are using doesn't belong to the right app.
Check the following:
1) The app id
2) The app secret (should be of the specific app)
3) The access token (should be for the app specified above)
In case you still need it - in the explorer you must haven't selected the app. This is on the top right corner. By default, it sets the app to Graph Api Explorer, click on the drop down menu, and choose your actual app.
Cheers!

facebook - Like a page through API

I'd like my application to like a facebook page on behalf of the user with an API call.
I saw this part of the documentation and tried to make the following post request:
https://graph.facebook.com/101544000571/likes?access_token=MY_ACCESS_TOKEN
where 101544000571 is a page id and got the following error:
{
"error": {
"message": "(#3) Application does not have the capability to make this API call.",
"type": "OAuthException",
"code": 3
}
}
I thought it's a permission problem but the application (in this case it's the graph API explorer application) has all the permissions necessary.
What am I missing here?
You cannot like a page using the Facebook Graph API. It is not supported.
You can use the the Like button social plugin.
The doc mentions : "For Facebook Pages or websites that do not integrate with Facebook Authentication, developers should continue to use the Like button social plugin."

Remove facebook like using graph api

Using GET https://graph.facebook.com/288095787880494/likes/159222380758097 returns me
{
"data": [
{
"name": "Vote For Prophet Hazrat Muhmmad (PBUH) the best man of world",
"category": "Cause",
"id": "159222380758097"
}
],
"paging": {
"next": "https://graph.facebook.com/288095787880494/likes/159222380758097?format=json&limit=5000&offset=5000&__after_id=159222380758097"
}
}
Now i want to remove this like. How do I do that? When I use HTTP Delete I get the following error:
{
"error": {
"message": "(#3) App must be on whitelist",
"type": "OAuthException"
}
}
You are not allowed to remove likes for Facebook Pages. Only for post, comment and URL's owned by your application.
To be able to do this your application must be whitelisted by Facebook which can only be done by contacting Facebook directly (and will probably require some kind of agreement and cost you money as well...)
Sounds like maybe two issues. Maybe the same. But try what I suggest in #2. Maybe facebook is spitting out a false/misleading error message.
Your app and or page is currently on the facebook naughty list. "Error code: (#3) App must be on whitelist"
You need to use a PAGE access token and not a USER access token. "It says I need to switch back to my Username in order to do that though as I mentioned earlier this link has been liked by the Page"