I am trying to like a Facebook post posted from an account. I have the oauth token of the account but i cant figure out how to like a post from my php code. I have a facebook app and also have the app id and app secret for my facebook app. I want to do this using the PHP SDK Version 5.0.0.
Can anyone please help with this or direct me to the some documentation apart from the one here - https://developers.facebook.com/docs/reference/php/5.0.0
Thanks
Surprisingly enough the approach that i commented on Navin's answer worked just fine now.When i had tried it previously i had gotten a 'Url not recognised' error.
My code is as follows-
$test=array();
$like=$fb->post('/'.$post_id.'/likes',$test,$token);
In the $like variable i get an object of FacebookResponse with a status of success or failure.
I believe creating Facebook service is not an issue. Once created, you may set a default access token for easier access. You may then take the id of the post you want to like and do this -
$response = $fb->post('/'.$post_id.'/likes');
EDIT after Tushar's comment
$response = $fb->post('/'.$post_id.'/likes', array());
where $fb is a Facebook service with a default access token.
Hope this helps.
Related
I am using PHP 5.3.8, therefore I can't use the latest Facebook SDK which works only with PHP 5.4.X.
given a url, I'd like my server to tell if this is a facebook-like-page, or not.
Do I have to use OAuth? I used to use the graph-api, but now I get all weird errors. like no access-token provided, no authorization etc.
My code was using cURL with GET and accessed https://graph.facebook.com/.urlencode("THE_PAGE_URL");
I don't know if this is not an overkill to do a whole authorization from my server, and if so, to whom? I must say I am lost in the facebook documentation, frankly.
I tried this sample code from Facebook, which does not work at all.
Is there a simple way to get info about a public like-page from facebook?
An easy way to make calls using the Facebook Graph API is with their Graph API Explorer.
You have to be logged into your Facebook developer account to access it obviously, but it is really helpful if you're experimenting with making different calls to a Facebook page.
Regarding oAuth, I would also highly recommend that you obtain a permanent page access token. It's the best way to mitigate the complexities of Facebook's oAuth process.
facebook: permanent Page Access Token?
I have a question for Facebook App Developers :)
Is it possible to like a comment created by some user on any fanpage, via access_token and post request?
I read from https://developers.facebook.com/docs/graph-api/reference/object/likes that it should be possible, however I can't find a way to figure out how to get an object ID of a comment.
Should I use in my fb.api request - postid_commentid as an object id?
Thanks in advance!
You guess it right. The comment_id that you obtained as postid_commentid cann be used as the {object-id}. So simply make the call-
\POST /comment_id/likes
and the comment will be liked.
PS. you can always test the API call in Graph API Explorer
Hope that helps!
I have been trying to implement the new scope features that were recently added to the LinkedIn API. I am currently using the "simple-linkedinphp" library for as my LinkedIn oauth lib (http://code.google.com/p/simple-linkedinphp/ ).
Following the directions on the LinkedIn docs, I added the "scope" param to my request token URL as such:
const _URL_REQUEST = 'https://api.linkedin.com/uas/oauth/requestToken?scope=r_basicprofile+r_emailaddress';
However, this had little effect. I still get the same o-auth dialogue as before without any additional permissions for the e-mail address. Anyone get this working correctly in PHP yet? Any help here would be appreciated.
You need to create new Application API keys and use those to see the updated authentication screens.
I'm making a facebook app and have got as far as getting the user to allow my apps permissions, which then generates a code. Then using this code to get an access token. So I now have a variable in my PHP script containing the access token. Now how do I use this to post to the users wall?
The easiest way to post a message on the wall is through the graph api. You require the publish_stream permission to post status messages. You can simply do a POST with the desired message and the access token.
See the official facebook documentation for more details: http://developers.facebook.com/docs/reference/api/status/
Facebook changes their API so often, it's best to read their docs, if those are up to date...
Check in IRC #facebook as well.
But basically, you pass that token in to the API call somewhere, somehow and it's in their docs somewhere.
Unless FB has decided you don't need it or ignores it or doesn't want to allow that this week.
My problem is that I want to know the users that uninstall my facebook application. I have set a callback url for facebook to hit when someone uninstalls the app and all I get is a signed request POST variable which, according to facebook documentation should be a base64 json encoded object but it seems impossible to trace the user's facebook id in there. Actually it's more like random data.. :| Anybody knows how to parse this thing to get the fb uid?
I tried:
<?php
$data = json_decode(base64_decode($_POST['signed_request']));
?>
And still I don't get something valuable out of it..
Check this documentation on facebook: http://developers.facebook.com/docs/authentication/signed_request/
Especially the "Verifying and Decoding" section, where you will find code to decode your signed_request parameter.