Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieving facebook user wall posts through graph API

I'm currently working on a facebook app which captures wall posts for a specified user, page or group, after a user has authorized the app I quote the access_token that is returned to call the method

https://graph.facebook.com//feed?access_token=

this works fine for pages and groups as we only need a valid token, however for users the results are different depending on the relationship between the user who authorized the app the user whose posts are being captured.

For example if there is no relationship between the two users some posts are not returned even though they are public and displayed when you view the profile of the user, however if they are friends more posts are returned.

Can someone please explain this behaviour? And is it possible to obtain all posts using this method?

like image 764
Hai Avatar asked Dec 27 '22 07:12

Hai


1 Answers

Yes, per the permissions listed at https://developers.facebook.com/docs/reference/api/permissions the results of the call are different depending upon the relationship.

However when things are public and you use an access token that doesn't belong to the user, then no results are returned. I cannot remember a time when this wasn't this way. For some odd reason (by design or omission on Facebook's part) using the graph API to get at public posts using a user access token just doesn't want to work.

For example, You can see some public items here

http://www.facebook.com/zuck http://graph.facebook.com/zuck

However, you cannot seem to get any feed from here without an access token

https://graph.facebook.com/zuck/feed

{
   "error": {
      "message": "An access token is required to request this resource.",
      "type": "OAuthException"
   }
}

Let's try adding an user access token that does not belong to zuck or a friend of zuck. https://graph.facebook.com/zuck/feed?access_token={UserAccessToken}

And here's what we get:

{
   "data": [

   ]
}

What about an app access token? Let's try https://graph.facebook.com/zuck/feed?access_token={AppAccessToken}

{
   "error": {
      "message": "Invalid OAuth access token signature.",
      "type": "OAuthException"
   }
}

So as you can see, it's difficult to get things via the graph that are not in alignment with your access token.

like image 158
DMCS Avatar answered Dec 31 '22 15:12

DMCS