【发布时间】:2012-04-23 04:16:25
【问题描述】:
我有这个代码...
require_once "facebook.php";
$app_id = "xxxxxx";
$app_secret = "xxxxx";
$facebook = new Facebook(array(
"appId" => $app_id,
"secret" => $app_secret,
"cookie" => true
));
$random_file = rand();
copy('http://alylores.x10.mx/gd/clean2/pic.php', 'temp/'.$random_file.'.jpg');
$img = realpath("temp/".$random_file.".jpg");
// allow uploads
$facebook->setFileUploadSupport("http://" . $_SERVER['SERVER_NAME']);
// add a photo
$photo = $facebook->api("/".$_POST['fid']."/photos?access_token=".$_POST['foauth'],"POST",
array(
"source" => "@" . $img,
"message" => "This photo came from my app."
)
);
echo "<script type='text/javascript'>parent.iframe_callback();</script>";
unlink('temp/'.$random_file.'.jpg');
我正在尝试将照片从 IFRAME 上传到用户的照片中...... facebook id 和 oauth_token 使用来自父窗口的发布请求传递..
当我检查时......它返回这个......
Fatal error: Uncaught OAuthException: A user access token is required to request this resource.
thrown in /home/alylores/public_html/gd/clean2/base_facebook.php on line 1033
但是当我通过echo() 检查oauth_token 是否存在时
oauth_token 确实存在....
谁能帮我解决这个问题???
【问题讨论】:
-
array( "access_token" => $_POST["foauth"], "source" => "@" . $img, "message" => "这张照片来自我的应用程序。" )
-
我认为 php sdk 本身会添加访问令牌,因此您无需将其添加到请求路径中。试试 $facebook->api('/'.$_POST['fid'].'photos')
标签: facebook facebook-graph-api upload photo