Facebook的图形API上传照片错误

问题描述:

我有这样的代码......Facebook的图形API上传照片错误

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的idoauth_token使用通过从父窗口post请求..

,当我检查......它返回....

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 

但是当我检查oauth_token存在echo() oauth_token确实存在....

有人可以帮我解决这个问题吗???

+0

阵列( “的access_token”=> $ _POST [ “foauth”], “源”=> “@”。$ IMG, “消息”=> “这张照片从我的应用程序来的。” ) – 2012-04-23 04:44:32

+0

我认为php sdk自己添加了访问令牌,因此不需要将它添加到请求路径中。试试* $ facebook-> api('/'.$_ POST ['fid']。'photos')* – 2012-04-23 06:21:05

array("access_token" => $_POST["foauth"], "source" => "@" . $img, "message" => "This photo  came from my app.")