Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Like posts over Facebook graph api

HI! I have little problem with facebook PHP SDK..I want to like a post, or something else via facebook PHP SDK..I am doing this code, I think it should be right, but  apparently it's not working..The given error code is, the PHP SDK dont know this kind of POST request(the generated link is definitely alright). What I have seen on Facebook Developers page is about the same..There is an example of Curl command, and I the PHP SDK is doing this requests over Curl (propably).

$this->getFacebook()->api("/"+$id+"/likes", 'post'); This is what I am using in my code and it's not working(Facebook API Exception unsupported post request).

Maybe, I have bad syntax in my code, but, for example, when I want to post a status to my Profile, it's working..Another cause which confused me, was when I tried to fetch these data over Graph api(on the documentation page is written, I should use address like graph.facebook.com/POST_ID/likes)...

You can comment on or like a post by posting to https://graph.facebook.com/POST_ID/comments and https://graph.facebook.com/POST_ID/likes,respectively:

curl -F 'access_token=...' \ https://graph.facebook.com/313449204401/likes <=this is from facebook documentation

And all these requests or commands(liking ones, comments have I not yet tried) are putting me back a JSON array which contents any already existing likes, but my like is nowhere.

Does anyone know what to do?How to like a post from PHP..There are other SKDs like FQL, but I haven't any knowlegde with it, so I like rather to use the standard PHP SDK(but if is there some possibility how to call for example FQL from PHP SDK, here I am:))

Please help..

like image 485
simekadam Avatar asked Dec 26 '10 18:12

simekadam


1 Answers

Okay, after a couple of tests don't use the plus sign + when sending the parameter as the ID alone will be send as argument to the api method without / and /likes so use:

$this->getFacebook()->api("/".$id."/likes", 'post');

Or even better:

$this->getFacebook()->api("/$id/likes", 'post');

Also make sure that you have the publish_stream extended permission, refer to this document.

like image 142
ifaour Avatar answered Sep 25 '22 02:09

ifaour