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
}
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 have been hammering away at this problem for the last day. I really hope someone can help me out. I would be very grateful.
What I am trying to do is fetch event data from a Facebook Page. I looked over the documentation, which says this about reading Pages data:
Reading
A Facebook page
Permissions
For pages that are published, you need:
An app or user access token to view fields from fully public pages.
So what I did was I obtained an app access token via:
GET https://graph.facebook.com/oauth/access_token?
client_id=YOUR_APP_ID
&client_secret=YOUR_APP_SECRET
&grant_type=client_credentials
which then returned
access_token=MY_APP_ID|MY_APP_ACCESS_TOKEN
After this I followed the documentation and made the following call
https://graph.facebook.com/v2.4/129511477069092/events?fields=id,cover,name,venue,description&access_token=MY_APP_ID|MY_APP_ACCESS_TOKEN
This returned:
{
"data": [
]
}
So after some fiddling around I was able to make the call by switching to version V2.2 and by creating an access key with Facebook API Graph explorer tool(no permissions granted).
GET https://graph.facebook.com/v2.2/129511477069092/events?
fields=id,cover,name,venue,description&
access_token=ACCESS_TOKEN_FROM_FACEBOOK_API_EXPLORER_TOOL
The page I am trying to retrieve data from is public and so are the events, so I can't figure out what is going on. I know I am super close since I am able to retrieve the data with the token provided by the Facebook API Graph Explorer Tool. The thing with using this token is that it only last a few hours and I need something that is going to last longer such as an app access token. I have done some research on Stackoverflow and found similar questions, but none of them solve my problem. Any help will be appreciated to the max! Thanks.
Looks like a bug of v2.4 to me. It works with v2.3 if you remove the deprecated venue field:
https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=129511477069092%2Fevents%3Ffields%3Did%2Ccover%2Cname%2Cdescription&version=v2.3
If the version is changed to v2.4, it returns an empty result.
https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=129511477069092%2Fevents%3Ffields%3Did%2Ccover%2Cname%2Cdescription&version=v2.4
There's no documentation about this in the changelog at
https://developers.facebook.com/docs/apps/changelog#v2_4
so I guess it's a bug. There's already a bug report at
https://developers.facebook.com/bugs/443054055873667/
with status assigned. If you have an app that supports v2.3, I'd suggest you prefix your request like this:
GET /v2.3/129511477069092/events?fields=id,cover,name,description
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.
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 ..