Saturday, January 8, 2011

Post on facebook wall from my website

Here is the php-curl script where you can post on facebook wall through your web site.

require_once 'facebook/facebook.php';
$aplication_id='YOUR_APPLICATION_KEY';
$facebook_api_key='YOUR_API_KEY';
$facebook_api_secret='YOUR_SECRET_KEY';

$facebook = new Facebook(array(
'appId' => $facebook_api_key,
'secret' => $facebook_api_secret,
'cookie' => true
));

//------------------Access Token---------------------------------------

$param='fbs_'.$aplication_id;
$string=substr($_COOKIE[$param], 15, strlen($_COOKIE[$param])-15); // we got the access token
$arr=explode("&",$string);
$token=$arr[0];

$_curl = curl_init();
curl_setopt($_curl, CURLOPT_URL, "https://graph.facebook.com/me/feed?access_token=".$token);
curl_setopt($_curl, CURLOPT_HEADER, false);
curl_setopt($_curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($_curl, CURLOPT_POST, true);
curl_setopt($_curl, CURLOPT_POSTFIELDS, $arr_attachment);
curl_setopt($_curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($_curl, CURLOPT_SSL_VERIFYPEER, 0);
$result = curl_exec ($_curl);
curl_close($_curl);

?>













Wall Post

Enter Message:
Enter Link:
Enter Title:
Enter Caption:
Enter Description:


No comments:

Post a Comment