Simple, imagine I am posting a wall post or an event on a random Facebook Page from a PHP script, and I want to delete the item. I simply use this :
$facebook->api('/'.FacebookId,'DELETE');
Of course, the FacebookId is structured like : userid_postid
But that doesn't work. To see why, I simply go to this URL :
https://graph.facebook.com/" + postID + "?method=delete&access_token=" + AccessToken;
Here is the result :
{
"error": {
"message": "(#200) Permissions error",
"type": "OAuthException",
"code": 200
}
}
By lurking around stackoverflow, I found this bug : http://bugs.developers.facebook.net/show_bug.cgi?id=12777
It is still not resolved.
So if anyone knows how to get this permission, I would appreciate your help.
According to the documentation:
You can delete a post as long as your application created the post.
You delete a post by issuing an HTTP DELETE request to the POST_ID
object with publish_stream permission.
Is this the case? Has your app created the post? does it have the "publish_stream" permissions?
I just tried it using the graph explorer, I created a post by POSTing to the me/feed, got back an id (USERID_POSTID) and then issues a DELETE request to the id, and it worked well (the returned response was "true").
Related
I am going insane...
After Googling, searching here and pulling each of my hairs out one by one, I'm stuck.
I am trying to automate posts to a Facebook page and am calling the following:
https://graph.facebook.com/oauth/authorize?client_id=XXXXXXXX&scope=publish_actions,publish_pages,manage_pages&redirect_uri=http://www.example.com
Followed by:
https://graph.facebook.com/oauth/access_token?client_id=XXXXXXX&redirect_uri=http://www.example.com&client_secret=XXXX&code=XXXXXX
This successfully gives me the access token, but when I try to use the Graph API explorer to post to the page (of which I am an Admin), I get the following error:
{
"error": {
"message": "(#200) Permissions error",
"type": "OAuthException",
"code": 200
}
}
I've tried different permissions, different roles for page users and about everything else I can think of! Could anyone shed some light on this? I'm at my wits end.
Can you try page access_token for facebook page publishing, not user access_token.
https://graph.facebook.com/v2.3/me/accounts
I'm looking for informations about this fanpage : https://www.facebook.com/gabrielmedinasurf
when I call the graph API (v1.0) at https://graph.facebook.com/gabrielmedinasurf
I get nothing but a RTFM message :
{
"error": {
"message": "Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100
}
}
This process was supported a month ago. Does anyone had to face the same problem ?
I know the page ID : 206550296052269
but calling the API with it gave me the same result (https://graph.facebook.com/206550296052269)
Note : The v1.0 should be available until April 30, 2015 (source : https://developers.facebook.com/docs/apps/changelog)
Any help is welcome
NOTE : On this older post from SO, the process seems to work : Get Facebook fan page ID
Always use an Access Token for any Graph API call. That being said, the Page may be restricted by age or location, an App Access Token is not good enough in that case. You can only use a User Access Token or Page Access Token. I just tried with a User Token and it worked for that Page.
If you don´t know how to handle the different Access Tokens, take a look at the following links:
https://developers.facebook.com/docs/facebook-login/access-tokens
http://www.devils-heaven.com/facebook-access-tokens/
I have a web application that uses Facebook API. Now, I'm facing with an issue on getting the total of likes from a user's post.
I have a long lived "userToken" valid for 2 months with the following scopes: public_profile, email, manage_pages, publish_actions
I use "POST /feed" to send a link into the user's timeline and I get a post ID.
Then, I try to get the total of likes for this post with "GET /{POST_ID}/likes?sumary=true" and I get ZERO likes even if the post has many likes.
{
"data": [
],
"summary": {
"total_count": 0
}
}
I tried to use only "GET /{POST_ID}" to get post information and I get the following json response:
{
"error": {
"message": "Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100
}
}
I have this issue only when I post to a user's timeline. However, when I post to a Facebook page, I can get the post ID and the numer of likes.
I made a test by adding read_stream scope and I can get the post information. However I read in API documentation that this permission has a limited use: "This permission is granted to apps building a Facebook-branded client on platforms where Facebook is not already available"
Then, I started to check other applications that get post likes and I noticed that they are using only public_profile, email, manage_pages, publish_actions. They are not using read_stream.
So, my question is how they can get this information only with these scopes?
I hope anyone of you will be able to help me?
Thanks
Can you please check, if the post is public.
If you have the post id of a public post you can fetch the likes simply by requesting the endpoint you already mentioned.
To get your feed you need the read_stream or user_posts permission.
I am trying to fetch a Facebook page's events. I have before, but it doesnt work any more. I used this scriptto fetch the events.
$string = file_get_contents("https://graph.facebook.com/?$pageids&fields=events.limit($fblimit)&access_token=$token&method=GET");
$json_a=json_decode($string,true);
$pageids was a lot of different facebook ids (id1,id2,id2 ...)
I get this error message:
{
"error": {
"message": "(#100) Unknown fields: events.",
"type": "OAuthException",
"code": 100
}
}
Does anyone know what is wrong with my script? Is there a another way to fetch Facebook events?
The actual URL to get a page's events is something like this :
https://graph.facebook.com/PAGE_ID/events
I'm not sure how old the code is that you are fixing, but this is the correct method as stated in the documentation. events is a connection of the page object.
Reference: https://developers.facebook.com/docs/reference/api/page/#connections
Facebook has had restricted access of Events in API recently.
You have to do app review to have access to Pages API, Events API.
Please check section "Apps that Require App Review, Business Verification, and Supplemental Terms" of this url: https://developers.facebook.com/docs/apps/review
I created and APP on the Facebook.
Now I am trying to post a comment on the user's timeline using the Graph API but I cannot undestand what I need to do.
I already authorized the Application (I authorized this permissions: 'user_status,publish_stream,user_photos,email').
If I look on my profile -> privacy I can see that the APP can:
This app can: Post on your behalf
This app may post on your behalf, including status updates, photos and more.
Last data access:
Basic InformationToday
See details · Learn more
Posts on your behalf:
Who can see posts this app makes for you on your Facebook timeline?
Public
Notifications:
When to notify you?
The app sends you a notification
So this part seems OK.
On my application I do the following to try to post somenthing on my timeline (I need to post it when I am off line).
1) GET : https://graph.facebook.com/oauth/access_token?client_id=APPID&client_secret=*APP_SECRET*&grant_type=client_credentials
RESPONSE:
access_token = 422828347771671|UdQELQIf0N7krF4JUo7VwtPLTkk
2) GET: https://graph.facebook.com/search?q=myemail&type=user
RESPONSE:
_"error":_{
______"message":_"A_user_access_token_is_required_to_request_this_resource_",
______"type":_"OAuthException",
______"code":_102
___}
But reading the documentation (https://developers.facebook.com/docs/reference/api/#searching) it seems that this request does not need any kind of access token.
I also tried to add the access token, but the result is still the same.
3) I know my facebookid so I tried to use it directly:
POST: https://graph.facebook.com/100001139132403/feed
ARGUMENT:
access_token=422828347771671|UdQELQIf0N7krF4JUo7VwtPLTkk,
message=Hello
RESPONSE:
"error": {
"message": "(#200) This API call requires a valid app_id.",
"type": "OAuthException",
"code": 200
}
}
So I tried to add client_id=APPID and app_id=APPID, I tried to put one, the other and also both arguments as GET or POST but nothing changed.
I checked the APPId ad it is correct.
Do someone have any idea?
Thank you!
You cant simply generate a user access_token by querying to a URL. What you did gives the App access token and as the error say, you are trying to do something, that needs user access_token.
Refer and implement this : https://developers.facebook.com/docs/howtos/login/server-side-login/
And use that access_token for the rest of the processes.