2012-04-23 4 views
1

이 코드는 ... 페이스 북 그래프 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에서 사용자의 사진에 사진을 업로드 할 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 

을하지만 난 경우 검사 할 때 oauth_token 존재합니다 echo() oauth_token 존재하지 않습니다 ....

누군가가 나를이 일을 도와 줄 수 있습니까 ???

+0

배열 ( "access_token이"=> $ _POST [ "foauth"], "소스"=> "@". $ IMG> =, "메시지" "이 사진은 내 응용 프로그램에서왔다." ) –

+0

나는 php sdk가 액세스 토큰 자체를 추가하므로 요청 경로에 추가 할 필요가 없다고 생각한다. * $ facebook-> api ('/'.$_ POST [ 'fid']. 'photos') * –

답변

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