Using Facebook\'s Graph API, I\'ve been successful at publishing to a user\'s feed while the user is offline with only the publish_stream permission. I don\'t need the offline_
This is my answer. Above code does not work for me. But I made one for myself, that works perfectly. Here is the code.
Code for server side:
YOUR_APP_ID,
'secret' => YOUR_APP_SECRET,
));
if($_SESSION['access_token']!='') {
$access_token = $_SESSION['access_token'];
$user_id = $_SESSION['user_id'];
} else {
$access_token = $_REQUEST['access_token'];
$_SESSION['access_token'] = $_REQUEST['access_token'];
$user_id = $_REQUEST['user_id'];
$_SESSION['user_id'] = $_REQUEST['user_id'];
}
$user_id = $_REQUEST['user_id'];
$facebook->setAccessToken($_REQUEST['access_token']);
$post = array(
'message' => 'This message is posted with access token - ' . date('Y-m-d H:i:s')
);
// and make the request
$response = $facebook->api('/me/feed', 'POST', $post);
?>
Code for client side:
YOUR_APP_ID,
'secret' => YOUR_APP_SECRET,
));
$user = $facebook->getUser();
if ($user) {
try {
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
// The access token we have is not valid
$user = null;
}
}
?>
Login with Facebook
Logout from Facebook
Post Into Wall
Please disable "Remove offline_access permission:" from fb apps advance setting. by selecting disable radio button.