I am fetching my timeline from Facebook and I successfully able to get my timeline but when I login with my friend's Facebook account I received the following error-
{
"error": {
"message": "(#200) Requires extended permission: read_stream",
"type": "OAuthException",
"code": 200
}
}
I am the admin of the application on Facebook developer but my friend is not.
I have already approved following permissions from Facebook(see attached screen shot)
And below is the permission which I am using in my code-
FBSession* sess = [[FBSession alloc] initWithPermissions:[NSArray arrayWithObjects:#"public_profile",#"user_friends",#"user_birthday",#"email",#"user_education_history",#"user_work_history",#"user_hometown",#"read_stream",#"user_about_me",#"user_posts",#"publish_actions",nil]];
And here is the code to getting the timeline-
NSString *urlStringFacebook = [NSString stringWithFormat:#"https://graph.facebook.com/me/home?format=json&&access_token=%#&&limit=90",[[FBSession activeSession] accessTokenData]];
If I submit the read_stream permission to Facebbok for review the reject it due to the following reason(see screenshot below)-
And one more thing when I login with my account they ask me to allow for news feed(read_stream) permission but when my friend login they don't ask for that permission.
When I try to get the same thing on Graph API explorer then the data comes fine.
Please let me know what I am missing in the whole process.
Thanks
You are trying to use /me/home, which needs read_stream as you can read in the docs: https://developers.facebook.com/docs/graph-api/reference/user/home
...and that permission will not get approved: https://developers.facebook.com/docs/facebook-login/permissions/v2.3#reference-read_stream
Use /me/posts or /me/feed instead, those endpoints need user_posts and you got that permission approved already: https://developers.facebook.com/docs/graph-api/reference/v2.3/user/feed
Btw, this is explained very well in the changelog: https://developers.facebook.com/docs/apps/changelog#v2_3_new_features
You can get Home Timeline post using user_posts.
Using /me/feed you can get all post from others and you. go to Developer graph API Explorer Graph API Explorer.
Use /me/feed instead of /me/home, with the already granted user_posts permission this should work. This endpoint also returns other posts from the user's timeline, not only those from the user himself (/me/posts)...
Related
I am testing the facebook graph API comments
https://developers.facebook.com/docs/graph-api/reference/v2.12/object/comments
I checked my permission for the access token it contains the permission, which required by API. see the screenshot
I test my object-id (1797963943566411_1975256375837166) which is correct see me screenshot
Change the request method to POST and adding post data {"message": "haha"}
I get the error message shows:
"(#3) Publishing comments through the API is only available for page access tokens" see my screenshot
As you can see the first step checking, I have all the permission that the
API required.
Can any one see any sort of error in this process?
Try another way still not work.
I have a user who post a photo on his own facebook page.
I logged in with this user and give this user all permissions see the screenshot
enter image description here
call /me/accounts to get page access token
enter image description here
copy the page access token into the Graph API Explorer's access token field
call
GET: 1797963943566411_1975256375837166/likes
is working fine
But call POST: 1797963943566411_1975256375837166/likes
Get error response:
{
"error": {
"message": "(#200) Permissions error",
"type": "OAuthException",
"code": 200,
"fbtrace_id": "GtEaBfyXrUD"
}
}
The reason is Facebook changed the API behaviour. We are no longer to use api to like any POST on our time line. API can only like or comments on facebook page. Sad face !!!!
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'm trying to post to a facebook page (as the page and as the admin user with each one access token) with just a parameter 'message'.
I've the same error in php and in Graph API Explorer in both cases:
{
"error": {
"message": "(#1) An unknown error occurred",
"type": "OAuthException",
"code": 1,
"error_data": {
"kError": 1455002
}
}
}
The same post to the API adding a paremeter link or just link without message works fine.
The user has granted those permissions: create_note, email, manage_pages, photo_upload, publish_actions, publish_stream, share_item, status_update, user_friends, video_upload.
The app is in Sandbox Mode and the user is a test user, not a real one.
I'm able to write to user feed and to create custom actions for him.
I've verified both, the page access token and the user access token with Access Token Debugger.
I've already reviewed a lot of questions in stackoverflow, tutorials and blog posts.
What am I missing?
UPDATED: I can't either post a link in page with app access token.
I went to https://developers.facebook.com/tools/explorer?method=GET, set up there ID of my Facebook page, set up there the correct permission for posting statuses on my FB timeline and generated access token.
Then I wanted to extend this short-live token on the long-term (60 days long valid token). So I did following - I put this URL to the browser:
https://graph.facebook.com/oauth/access_token?client_id=APP_ID_OF_MY_FB_APP&client_secret=SECRET_ID_OF_MY_APP&grant_type=fb_exchange_token&fb_exchange_token=GENERATED_ACCESS_TOKEN_FROM_THE_FIRST_STEP
and in the browser I saw this error message:
{
"error": {
"message": "The access token does not belong to application APP_ID_OF_MY_FB_APP",
"type": "OAuthException",
"code": 1
}
}
Which is weird, because the APP_ID of my Facebook app is correct, I've tried to post on the wall of the Facebook page and it was working.
But when I try to get extended access token, I am getting the error above.
What's wrong with the access?
Thank you
This almost certainly means what the error says, which is that GENERATED_ACCESS_TOKEN_FROM_THE_FIRST_STEP is not actually from the app ID that you're using in the APP_ID_OF_MY_FB_APP parameter
Check the access token you're trying to extend in Facebook's Debug Tooland ensure it was actually generated for your app
Your AppID param is not the same to the AppID in developers.facebook.com
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.