您好我遇到致命错误问题:未捕获OAuthException:必须使用活动访问令牌来查询有关当前用户的信息。在第1024行的...... / src / base_facebook.php中抛出 这是代码
有人可以帮助我吗?好吧,我把所有的东西放在那里,App_ID,APP_SECRET和其他,但它给出了这个错误。 <?php
session_start();
require_once 'src/facebook.php'; // EDIT
$app_id = "APP_ID";
$app_secret = "APP_SECRET";
$redirect_uri ="http://URL_TO_APP/main.php";
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true
));
$user = $facebook->getUser();
$user_profile = $facebook->api('/me');
$coded = $_REQUEST['code'];
$access_token = $facebook->getAccessToken();
$name = "".$user_profile['name']."";
$fbid = "".$user_profile['id']."";
function RandomLine($filename) {
$lines = file($filename) ;
return $lines[array_rand($lines)] ;
}
$reason = RandomLine("reason.txt");
$canvas = imagecreatefromjpeg ("PHOTO.jpg"); // background image file
$black = imagecolorallocate( $canvas, 0, 0, 0 ); // The second colour - to be used for the text
$font = "TAHOMABD.TTF"; // Path to the font you are going to use
$fontsize = 16; // font size
$birthday = "".$user_profile['birthday']."";
$death = "".date('d/m/Y', strtotime( '+'.rand(0, 20000).' days'))."";
imagettftext( $canvas, 24, 0, 100, 125, $black, $font, $name ); // name
imagettftext( $canvas, 10, -1, 122, 202, $black, $font, $death ); // death
imagettftext( $canvas, 20, -1, 110, 170, $black, $font, $birthday ); // birthday
imagettftext( $canvas, 24, 0, 90, 235, $black, $font, $reason ); // reason
imagejpeg( $canvas, "img/".$fbid.".jpg", 50 );
$facebook->setFileUploadSupport(true);
//Create an album
$album_details = array(
'message'=> 'CLICKABLE_MESSGAE_ABOVE_PHOTO',
'name'=> 'NAME_OF_PHOTO'
);
$create_album = $facebook->api('/me/albums', 'post', $album_details);
//Get album ID of the album you've just created
$album_uid = $create_album['id'];
//Upload a photo to album of ID...
$file='img/'.$fbid.'.jpg'; //Example image file
$photo_details = array( 'message'=> 'WHAT_MESSAHE YOU_WANT_THE_USER_TO_SAY', 'image' => '@' . realpath($file) );
$upload_photo = $facebook->api('/'.$album_uid.'/photos', 'post', $photo_details);
$upphoto = $upload_photo['id'];
ImageDestroy( $canvas );
header("location: URL_WHERE_YOU_WANT_USER_TO_GO_AFTER_ACCEPTING")
?>