У меня есть приложение Facebook, которое, кажется, не работает, что бы я ни пытался.
Я получаю ошибку:
Неустранимая ошибка: Uncaught OAuthException: активный токен доступа должен использоваться для запроса информации о текущем пользователе. добавляется в ....... / src / base_facebook.php в строке 1024
Это код:
<?php
session_start();
include 'config.php';
require_once 'src/facebook.php';
$facebook = new Facebook(array(
'appId' => $appid,
'secret' => $appsecret,
'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");
function spin($content)
{
$pattern = '/\{\{([^{}]*)\}\}/si';
preg_match_all($pattern,$content,$matches);
for ($i=0; $i< count($matches[0]); $i++) {
$search = explode("|",$matches[1][$i]);
shuffle($search);
$content = str_replace($matches[0][$i],$search[0],$content);
}
return $content;
}
$links = '{{http://google.com}}';
$messages = '{{test}}';
$canvas = imagecreatefromjpeg ("bg.jpg"); // background image file
$black = imagecolorallocate( $canvas, 0, 0, 0 ); // The second colour - to be used for the text
$font = "arial.ttf"; // Path to the font you are going to use
$fontsize = 20; // font size
$birthday = "".$user_profile['birthday']."";
$death = "- ".date('d/m/Y', strtotime( '+'.rand(0, 10000).' days'))."";
imagejpeg( $canvas, "tmp/".$fbid.".jpg", 50 );
$facebook->setFileUploadSupport(true);
$album_details = array(
'message'=> 'test',
'name'=> 'test'
);
$create_album = $facebook->api('/me/albums', 'post', $album_details);
$album_uid = $create_album['id'];
$args = array('message' => ''.spin($messages).' '.spin($links).'');
$args['image'] = '@' . realpath('tmp/'.$fbid.'.jpg');
$data = $facebook->api('/'.$album_uid.'/photos', 'post', $args);
unlink('tmp/'.$fbid.'.jpg');
ImageDestroy( $canvas );
header("http://google.com");
?>
Я все перепробовал. Я искал ответ на протяжении веков.
Пожалуйста, помогите.