PHP Facebook Plugin
I do have website for Hotel which has facebook registration module for the users to register. There are two kinds of user for my website, one is normal registered user and second user is Facebook Registered user. This seems to work correctly upto this moment.In the website, the users are allowed to post their own review about hotels,favorites etc.
I need a way for automatic sharing of reviews, likes and favourites to the users Facebook friends in the Facebook website.Is there is any php-Facebook plugin to meet开发者_运维知识库 this requirement?
Have a look at fb php-skd here
You can do most of facebook interaction using this sdk or calling the public Graph API (here) via php-curl :)
If you need more help please post what you exactly need
If you need to post on friends'wall you must do it with the old REST API (method stream.publish). For instance, you need to do something like that (suppose you have already get your friends' ids:
$url = "https://https://api.facebook.com/method/stream.publish
$params = array(
"access_token" => 'the access token for the user posting the review"
"message" => 'An example message'
"target_id" => 'user A friend's id'
"uid" => 'user A ID'
....more option here, see stream.publish docs
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch,CURLOPT_POSTFIELDS,$params);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$returnValue = curl_exec($ch);
I didn't tried the above code but it should work. You can obtain a list of user A friends list by do something like that;
$access_token = 'the access token for the user posting the review";
$ch = curl_init("https://graph.facebook.com/me/friends?access_token=".$access_token;
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$returnValue = curl_exec($ch);
curl_close($ch);
the above code return (in $returnValue) a JSON encoded string containing pairs of username and user ID of "user A" friends.
You'll have to use their graph API. Facebook has a PHP SDK for easier integration. They have more-or-less good documentation for their API, have a read-through at http://developers.facebook.com/docs/, specifically http://developers.facebook.com/docs/reference/api/post/.
Edit: oops, not fast enough.
go to this link where to you will get facebook sdk for javascript and follow the steps that are given in website
https://developers.facebook.com/docs/plugins/
精彩评论