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..
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With