I'm trying to post a message on a page's wall as the page itself without any user connected.
For now, the first part works fine, but I need a connected user to do it. I've heard I need a seesion ID to do it offline, but I don't know how to get it and how to use it.
For now, my code is:
$facebook = new Facebook(array('appId' => $appID, 'secret' => $appSecret));
$user = $facebook->getUser();
try
{
$pageInfo = $facebook->api("/{$pageID}?fields=access_token");
if(!empty($pageInfo['access_token']))
{
$args = array(
'access_token' => $pageInfo['access_token'],
'message' => $message
);
$postID = $facebook->api("/{$pageID}/feed", 'post', $args);
}
}
catch (FacebookApiException $e)
{
echo '<pre>'; var_dump($e); echo '</pre>';
$user = null;
}
You need the offline_access permission set, then you can do what you need. Check this out it will show you what to do: http://eagerfish.eu/using-facebook-off-line-access-to-post-on-users-wall/