Facebook图形api上传照片错误

时间:2012-04-23 04:16:25

标签: facebook facebook-graph-api upload photo

我有这个代码......

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使用来自父窗口的帖子请求传递。

当我检查时......它会返回....

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确实存在....

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

1 个答案:

答案 0 :(得分:0)

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