脸书图形 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

但是当我通过echo()检查oauth_token是否存在时oauth_token确实存在。

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

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

最新更新