I'm able to get page feeds using Graph API with Page ID. However, when I try to get some user's Public Posts, the array returns a null value.
try
{
$uid = $facebook->getUser();
$me = $facebook->api('/100001712169642'); //
echo "Welcome User: " . $me['name'] . "<br />";
//access permission
$permissions_needed = array('publish_stream', 'read_stream', 'offline_access', 'manage_pages');
foreach ($permissions_needed as $perm) {
if (!isset($permissions_list['data'][0][$perm]) || $permissions_list['data'][0][$perm] != 1) {
$login_url_params = array(
'scope' => 'publish_stream,read_stream,offline_access,manage_pages',
'fbconnect' => 1,
'display' => "page",
'next' => 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'],
);
$login_url = $facebook->getLoginUrl($login_url_params);
header("Location: {$login_url}");
exit();
}
}
//Access permission
$post_id = $facebook->api("/$uid/feed", "post", array("message" => "Hello World!"));
if (isset($post_id)) {
echo "A new post to your wall has been posted with id: $post_id";
}
} catch (FacebookApiException $e) {
echo ($e);
}
Now, even when I try - http://ift.tt/1DaA4lP - and I get the user ID for my friend, I can't retrieve his posts using $me = $facebook->api('/FriendUserID'). But I can retrieve mine.
It says invalid access token when I try it in debugger. Could somebody please explain to me how to generate a valid USER ACCESS token? (Not application) where I can user user's ID to get his public posts? Please help, this is really eating me for past some days.
Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire