According to the Facebook documentation, you can update the run status of an individual ad group via the ads api.
To do this, you submit a POST request to /<AD_GROUP_ID>/ with adgroup_status=X where X is your status (1 for active, 9 for paused, etc). However, making this request results in the status NOT changing, and the only response you get back from Facebook is a JSON representation of the Ad Group.
Has anyone been able to successfully submit ad group status updates to the facebook ads api? If so, are you using the method outlined above, or is there another trick to it?
thanks!
EDIT
I cross posted this into the Facebook Bug tracker in hopes to create a trail/awareness/find more people who were having this problem. https://developers.facebook.com/bugs/354657724569051
EDIT
An example of the request I'm making. This request is being tested from the Facebook Graph Explorer
https://graph.facebook.com/6003521999629?adgroup_status=9&method=POST&access_token=<access_token>
We have not been experiencing problems with changing adgroup_status. Try submitting the status number as an integer and then as a string (I don't remember which type they expect). Note that if the campaign is paused, setting the adgroup_status to 1 will actually change it to 8 (campaign_paused). The fact that you're getting the adgroup to redownload (I presume you have the redownload=1 parameter) tells me that your call is mostly correct. I just confirmed that this works:
curl -F "adgroup_status=9" \
-F "ids=..." \
-F "access_token=..." \
https://graph.facebook.com/
If you're making that API call and receiving the adgroup's details back instead of a 'true' response, it means you're making a GET request, not a POST request.
Update your code to make a HTTP POST request, and this will resolve your issue, John Pickard's answer above is an example of making a POST request in curl, but it will change depending on your application's language and/or which Facebook SDK you're using.
Related
I am trying to get the campaigns list from the Graph API Explorer. I'm using the request found at https://developers.facebook.com/docs/marketing-api/reference/ad-account/campaigns/.
GET /v2.8/{ad-account-id}/campaigns HTTP/1.1
Host: graph.facebook.com
I'm' business manager and admin of the page used for ads. I found the AD_ACCOUNT_IDs using the following request on the Graph API Explorer.
GET /v2.8/me/businesses HTTP/1.1
Host: graph.facebook.com
I choosed the one which had the higher privileges.
The error reported when submitting the first request for campaigns is:
{
"error": {
"message": "Unsupported get request. Object with ID '1015359838XXXXXX' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100,
"fbtrace_id": "DLyfwGbM8fi"
}
}
What's wrong?
Thanks in advance,
Mattia
#Ryan's answer saved my day. It may sound stupid/silly but I was doing this mistake and I was just stuck at it.
Going through the FB docs for using the Marketing Apis.
I was trying to build the custom audience, this is how the curl request looks like -
One of the basic things to keep in mind while using the Marketing API is, almost all the APIs ask for these two things -
1) ACCESS_TOKEN
2) AD_ACCOUNT_ID
For people who are just starting with the FB Marketing API or somehow stuck in finding these values, I will just tell you how to get these values, so that you don't have to waste your time as I did.
So for getting the ACCESS_TOKEN, go to your app dashboard then click Add Product and then select Marketing API. Once you added the product, this is how the screen should look like -
Now just check the permissions and click on the Get Token button, a token would be generated. Just copy the token in some file and save it.
Now for getting the AD_ACCOUNT_ID value, just go to the Adverts Manager page -
The number that is written inside the red box in you Adverts Manager page is your AD_ACCOUNT_ID.
The final step would be to go back to you app dashboard again, Settings > Advanced
Click on Ads API and then enter the AD_ACCOUNT_ID here. Thats it, you have finished the Access and Authentication process for using the marketing API via your App.
Now comes the part where I was doing the silly mistake. The curls request looks like this -
curl \
-F 'name=My new CA' \
-F 'subtype=CUSTOM' \
-F 'description=People who bought from my website' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.8/act_<AD_ACCOUNT_ID>/customaudiences
First I replaced ACCESS_TOKEN with its value.
Then instead of replacing only the <AD_ACCOUNT_ID> I replaced the whole string act_<AD_ACCOUNT_ID>, with the AD_ACCOUNT_ID value.
So I was getting this error while making request to the API which was -
{"error":{"message":"Unsupported post request. Object with ID '120574219' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https:\/\/developers.facebook.com\/docs\/graph-api","type":"GraphMethodException","code":100,"fbtrace_id":"YsSvKKwgLMQ"}}
I don't know why I made this mistake but I am sure this is one of the common mistake others are doing too. Since the response from FB was misleading, I wasted a lot of my time in understanding and reading on the API permissions and authentications.
Hope this article was helpful and save your time.
I similarly was having problems trying to retrieve a list of all campaign IDs within an ad account.
I already am able to retrieve campaign data by ID, so I obviously have permissions already.
But the Facebook error message is misleading.
When retrieving an ad account (in order to then display its campaigns or whatever you want within it), you need to retrieve by its ID prepended with 'act_'.
E.g you could request /act_123456789000001234/campaigns instead of /123456789000001234/campaigns.
Thanks so much to #Jan Sommer at https://stackoverflow.com/a/39974857/470749.
I was having trouble submitting an ad through the Facebook ads api, like I was doing before.
It seems a new problem has come up. The Api of course only gives me a generic error "Invalid Parameter" however in the past I noted this this comes up for basically any reason that ad creation fails and does not tell you anything specific. In a different situation I used curl to the Facebook graph because I noted that it will give you additional information. However not much more in this case. Note the error message below the code.
curl -X POST -F "name=Ad Administrator_15"
-F "campaign_id=xxxxxxxxxx995" -F "creative={'creative_id': xxxxxxxxxx795}" /
-F "adgroup_status=PAUSED" /
-F "access_token={access_token}" / "https://graph.facebook.com/v2.2/act_{account_id}/adgroups"
This is the error received
{"error":{"message":"Invalid parameter","type":"FacebookApiException","code":100,"error_subcode":1487757,"is_transient":false,"error_user_title":"Ad Ineligible for Feed Targeting","error_user_msg":"Your ad is ineligible for News Feed targeting."}}
In checking on the facebook ads error message page. The error is not even
listed, though many others are.
previously I was getting the invalid parameter message back from the API just because I had not put a payment profile on my ad account. But used curl instead to find out this message. But after that I was creating ads just fine. Seems like this is a new problem.
If I could ask Facebook directly. I would ask "Hey can you put some descriptive error messages on your failures so that developers can see how to fix problems?" I guess that's too much to ask.
Anyhow, I may note here that The Campain was newly created with the api, then the adset, then the ad creative with the ad image, all created fine with recorded IDs (I masked these ids mostly in the code shown here for security reasons). When using these id's even outside of the API with curl I get the failure noted. Here is what shows in the API for an error with the trace.
Invalid parameter
/var/www/turnkey/vendor/facebook/php-ads-sdk/src/FacebookAds/Http/Client.php(191): FacebookAds\Http\Exception\RequestException::create(Array, 500)
#1 /var/www/turnkey/vendor/facebook/php-ads-sdk/src/FacebookAds/Http/Request.php(276): FacebookAds\Http\Client->sendRequest(Object(FacebookAds\Http\Request))
#2 /var/www/turnkey/vendor/facebook/php-ads-sdk/src/FacebookAds/Api.php(140): FacebookAds\Http\Request->execute()
#3 /var/www/turnkey/vendor/facebook/php-ads-sdk/src/FacebookAds/Api.php(182): FacebookAds\Api->executeRequest(Object(FacebookAds\Http\Request))
#4 /var/www/turnkey/vendor/facebook/php-ads-sdk/src/FacebookAds/Object/AbstractCrudObject.php(248): FacebookAds\Api->call('/act_xxxxxxxx40...', 'POST', Array)
#5 /var/www/turnkey/application/modules/Ads/models/FacebookAdsApi.php(473): FacebookAds\Object\AbstractCrudObject->create()
Here is a thought, if anyone, including someone at Facebook since they own this site, could tell me what is going on, I would really appreciate it.
Thanks in advance.
The Facebook documented required length for the message body for an ad Creative is that it needs to be a minimum length of 1 character and a maximum length of 90 characters. Before what would happen is that ads could be created. Even with test content in the title and body of your ad. Then they would not be approved if Facebook did not like the content. Such as messages like "test title, test body" and things like this. Facebook seems to be evaluating the text on submission now, rather than on ad approval. I guess they want to cut down on unnecessary ad approvals. So with out updating their documentation. It seems there are new requirements for the body field. And perhaps the title field.
All I did was lengthen the body of the ad message from 17 characters to 38 characters. This did one of two things. It made the field long enough to pass a new undocumented restriction, or, by adding some more words to the text they decided that it wasn't test message.
Here is the problem with that thinking on their part though.
1 I am paying for the ad, I should be able to put the content I want in it. As long as it is meaningful and doesn't violate some obvious certain policies for content such as obscenity etc.
2 If it's about the length rather than the content. My ad that I am paying for that only has 17 characters, should be required to be longer if I just want to say something short.
I am new to using the Facebook API and just started playing around with it.
I was wondering if it is possible, for example an app, to delete past posts (that exists on the timeline, i.e, Can an app have the functionality to delete posts that exists before the app was started?)
Thanks.
Looking at the relevant documentation, you are able to delete a post only if it was your application that created it.
An app can delete a post if it published it
You have not stated which language/SDK you are using, but the above link has examples for each supported SDK.
Here is an example using the PHP SDK:
$response = $facebook->api(
"/{post-id}",
"DELETE"
);
What you would need to do is make a DELETE request to /post_id.
Keep in mind that you will need the publish_actions permission to perform this action.
This is tricky - the answer is yes and no.
You can use the API to get a list of old posts, but then you need to delete them via the browser. This tool does just that:
https://github.com/chander/social-network-cleaner
However, it's written in Python and requires a bit of tech know-how.
This is possible now
Delete a Post
To delete a Page post, send a DELETE request to the /{page-post-id} endpoint.
Before You Start
You will need the following:
The pages_manage_posts permission
The pages_read_engagement permission
A Page access token requested by a person who is able to perform the CREATE_CONTENT task on the Page that is being queried
Sample Request
curl -i -X DELETE "https://graph.facebook.com/{page-post-id}
?access_token={page-access-token}"
On success, your app receives the following response:
{
"success": true
}
I have question about the beta Open Graph stuffs.
The documentation I am looking at is this https://developers.facebook.com/docs/beta/opengraph/
I successfully define custom objects and actions. However, I cannot figure out how to link current user with other users.
For example, say I define a custom action 'kick'. I want the current user to be able to 'kick' one of his/her friends.
The closest object I can think of is 'profile', but when I pass user_id, 'http://www.facebook.com/profile.php?id=', or http://graph.facebook.com/, it does not work.
This is the requests I tried
POST https://graph.facebook.com/me/myapp:kick?access_token=abc&profile=http%3A%2F%2Fwww.facebook.com%2F123
POST https://graph.facebook.com/me/myapp:kick?access_token=&profile=123
POST https://graph.facebook.com/me/myapp:kick?access_token=abc&profile=http%3A%2F%2Fwww.facebook.com%2Fprofile.php%3Fid%3D123
POST https://graph.facebook.com/me/myapp:kick?access_token=abc&profile=http%3A%2F%2Fgraph.facebook.com%2F123
This is the response I get
{"error":{"message":"An unexpected error has occurred. Please retry your request later.","type":"OAuthException"}}
The profile given is for an external website. They call it external profile. Pretty misleading terms.
As you can see I used the following
curl -F 'access_token=TOKEN' \
-F 'profile=http://graph.facebook.com/zuck' \
'https://graph.facebook.com/me/MYAPP:kick'
And it gave the above.
I guess you can fill the external profile with meta info from the Facebook users and it will show alright (for example I can send the profile URL facebook.com/zuck instead), but it seems backwards, inefficient and not the intended usage.
For example feeding it my link.
curl -F 'access_token=TOKEN' \
-F 'profile=http://facebook.com/username' \
'https://graph.facebook.com/me/MYAPP:kick'
But the thing is ... I am not a musician.
It does though seem to look alright in aggregation view.
Which is interesting/weird since one of objects shown in this picture is a Facebook profile, so you would think they would give an example with Facebook profiles as objects.
Though they did say
We are now extending the Open Graph to include arbitrary actions and objects created by 3rd party apps and enabling these apps to integrate deeply into the Facebook experience
Which most likely means they want you to create arbitrary objects outside of Facebook.
Can you still link to other users?
Yes, but through tagging using tags=FacebookID1,FacebookID2 but it will be in the form of
phwd kicked a musician with Friend1 and Friend2 on [APP NAME]
I started researching this because I wanted to be able to delete a comment on the wall of a Facebook Event, because the "Remove post" doesn't seem to be applicable to comments on an Event wall. However, since I don't know if it is even possible I decided to see if I could mannually delete a post I made to my own wall first since that is possible. Note I am NOT using any SDK; I am just building the URL and entering it in the address bar in Firefox v3.6.17.
These posts have helped me alot since I am now starting:
Delete facebook post with Graph API - trouble getting this to work and
Facebook SDK and Graph API Comment Deleting Error
I can see the comment data and all its field via the following:
https://graph.facebook.com/[POST_ID]?access_token=[ACCESS_TOKEN]
`where [POST_ID] and [ACCESS_TOKEN] were got using the graph API.`
However, where do I put the "method=delete" command in the URL? I tried putting it at the end, like
https://graph.facebook.com/[POST_ID]?access_token=[ACCESS_TOKEN]?method=delete
but that results in a OAuthException stating "Invalid access token signature" because it seems to read the method as part of the access token.
I tried putting it after the post_id like
https://graph.facebook.com/[POST_ID}?method=delete?access_token=[ACCESS_TOKEN]
but that results in an Exception (Unsupported method) because it thinks "access_token=[ACCESS_TOKEN]" is part of the method being called.
I see one of the posts cited above states I have to prepend the userid to the object ID when deleting by using
DELETE https://graph.facebook.com/673509687_104812882909249?access_token={access_token}
`where 673509687 is my userID and 104812882909249 is the objectID`
But when I enter
DELETE https://graph.facebook.com/[POST_ID}?access_token=[ACCESS_TOKEN]
in the Firefox address bar it doesn't recognize it (I didn't think it would anyway) and uses it as a google search query.
How do I delete a comment if I have the comment_id and my access_token using the web browser?
You have a big problem with your urls :
https://graph.facebook.com/[POST_ID]?access_token=[ACCESS_TOKEN]?method=delete
Should be :
https://graph.facebook.com/[POST_ID]?access_token=[ACCESS_TOKEN] & method=delete
Identically,
https://graph.facebook.com/[POST_ID}?method=delete?access_token=[ACCESS_TOKEN]
should be :
https://graph.facebook.com/[POST_ID}?method=delete & access_token=[ACCESS_TOKEN]
So you have to use the ? before entering your parameters and then & between each parameter and the order should not have any importance ..