The code below is not working for some reason:
require './facebook.php';
$facebook = new Facebook(array(
'appId' => 'working_app_id',
'secret' => 'working_secret'
));
// Get User ID
$user = $facebook->getUser();
$token = $facebook->getAccessToken();
print $token; // token shows.
$attachment = a开发者_运维问答rray
(
'access_token'=>$token,
'message' => 'This is where the message will go.',
'name' => 'Name Text',
'link' => 'http://www.website.com',
'description' => 'Description text.'
);
$result = $facebook->api('/me/feed/','post',$attachment);
exit;
I am getting the following error:
Uncaught OAuthException: An active access token must be used to query information about the current user.
When I print the token, it appears to be a real token. I just have no idea what I could be doing wrong. All I want to do is post a very simple status update to my own page.
I don't know why I can't seem to figure this out. I'm banging my head against the wall on this one because it should just be so simple to post a quick little status update to my wall in Facebook from PHP.
Note: The App Type I created to get my appID and secret was a "Website".
Check out this answer, it appears that you are using the wrong method to get your access token.
Howto use FB Graph to post a message on a feed (wall)
精彩评论