Dear all,
In my website admin page.post a new property.the details are posted in my facebook fan page wall. I am using PHP SDK.
Some times its working fine.
Sometimes redirect to my return url it contains code parameter and stopped
i am using this code
Anyone help me
<?php
require_once 'src/facebook.php';
// configuration
$appid = '';
$appsecret = '';
$pageId = '';
$msg = $_REQUEST['fbtitle'];
$title = $_REQUEST['fbtitle'];
$uri = $_REQUEST['fburl'];
$desc = $_REQUEST['fbsum'];
$pic = $_REQUEST['fbimage'];
$facebook = new Facebook(array(
'appId' => $appid,
'secret' => $appsecret,
'cookie' => false,
));
$user = $facebook->getUser();
// Contact Facebook and get token
if ($user) {
// you're logged in, and we'll get user acces token for posting on the wall
try {
$page_info = $facebook->api("/$pageId?fields=access_token");
if (!empty($page_info['access_token'])) {
$attachment = array(
'access_token' => $page_info['access_token'],
'message' => $msg,
'name' => $title,
'link' => $uri,
'description' => $desc,
'caption' => $caption,
'picture'=>$pic,
'actions' => json_encode(array('name' => $action_name,'link' => $action_link))
);
$status = $facebook->api("/$pageId/feed", "post", $attachment);
$msg="<h2 align='center'>Sucessfully Posted On Facebook Wall</h2>";
}
else
{
$status = 'No access token recieved';
}
}
catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
} else
{
// you're not logged in, the application will try to log in to get a access token
header("Location:{$facebook->getLoginUrl(array('scope' => 'photo_upload,user_status,publish_stream,user_photos,manage_pages'))}");
}
echo $msg;
?>