I am able to like a public facebook post made by my friend using graph api as long as we are friends on facebook. I unfriended him and then tried the same thing but it wouldn't work.
Permissions obtained : publish_stream,read_stream,publish_actions,read_mailbox
To like the post I used "POST /POST_ID/likes?access_token=SECRECTACCESSTOKEN"
I use apigee.com to test .
Is it not possible to like a public status or post using graph api ?
I did try to like the post as a normal user through facebook. It worked fine.
What am I doing wrong?
Thanks in advance ! :)
The response I get when I'm friends with the user : True
The response I get when I'm not friends with the user :
{ "error": { "message": "(#200) Permissions error", "type": "OAuthException", "code": 200 } }
It is possible to like public posts on Facebook using the API. However, if you friend has restricted privacy settings, the public may not be able to comment / like their posts.
A good giveaway is if you are able to see the post, but can only Share it - the Like and Comment actions are hidden:
See if your friend has restricted privacy options, preventing you from Liking / Commenting on their posts. Then retest your API call on a different public post which allows Liking / Commenting.
Edit
Also, make sure you are calling the API correctly:
POST https://graph.facebook.com/{object_id}/likes
The Object ID can be obtained from the API, and is usually the last part (after the underscore) of the actual ID: 1234567890_009988776655
, i.e. 009988776655
is the actual object ID.
Try to use "Graph API Explorer".
Since you receive "Permission Error". Try to double check permission list.
This method is right. But used to likes an object.
POST /[POST_ID]/likes?access_token=SECRECTACCESSTOKEN
For Posting a public status:
POST /[USER_ID]/feed?access_token=SECRECTACCESSTOKEN&message=HELLO
If you're running Unix, try to use this:
curl -F 'access_token=...' \
https://graph.facebook.com/OBJECT_ID/likes
curl -F 'access_token=...' \
-F 'message=Hello. I like this new API.' \
https://graph.facebook.com/[USER_ID]/feed