$photo_details = array(
'message'=> $image->description().' '.$site_adr.$image->id().'/'.cleanSEOstring(strtolower(trim($image->title()))).'-cover-photo',
'redirect_uri'=> 'http://www.exampleurl.com',
'scope'=>'publish_stream');
$photo_details['image'] = '@' . realpath($photo);
try
{
$upload_photo = $facebook->api('/'.$album_uid.'/photos', 'POST', $photo_details);
@unlink($file);
header('location:https://www.facebook.com/profile.php?id='.$userMe['id'].'&v=wall');
}
catch(FacebookApiException $e)
{
header('location:http://www.somethingwentwrong.com');
}
它仍然会重定向到somethingwentwrong.com,我做错了什么?
标题中所述的例外情况是“发生了一次unknwon错误”,这是它在catch语句中返回的对象:
object(FacebookApiException)#5 (7) { ["result:protected"]=> array(1) { ["error"]=> array(3) { ["message"]=> string(30) "An unknown error has occurred." ["type"]=> string(14) "OAuthException" ["code"]=> int(1) } } ["message:protected"]=> string(30) "An unknown error has occurred." ["string:private"]=> string(0) "" ["code:protected"]=> int(0) ["file:protected"]=> string(48) "/var/www/mysite/fb-sdk/base_facebook.php" ["line:protected"]=> int(1106) ["trace:private"]=> array(4) { [0]=> array(6) { ["file"]=> string(48) "/var/www/mysite/fb-sdk/base_facebook.php" ["line"]=> int(810) ["function"]=> string(17) "throwAPIException" ["class"]=> string(12) "BaseFacebook" ["type"]=> string(2) "->"
答案 0 :(得分:3)
找出异常错误消息是什么。所以做这样的事情:
} catch {
error_log('caught exception: '. $e);
header('location:http://www.somethingwentwrong.com');
}
如果你得到OAuthException: (#803) Some of the aliases you requested do not exist
,那么确保$ album_uid是一个字符串,而不是一个int。
还要确保用户已为您的应用授予user_photos
权限。异常错误消息将告诉您。
如果您要将照片发布到FB页面,则需要使用页面访问令牌。
您的代码看起来不错,但我认为'scope'
和'redirect_uri'
不会对Graph API调用做任何事情。
答案 1 :(得分:2)
我不认为这是你的错。我最近看到一个非常类似的问题,照片上传失败,“发生了未知错误”。这是在我们所有客户帐户中随机发生的,但最常见的是两个帐户(80-90%的上传失败)。有时重试上传将解决问题,但通常也会失败。
我于9月13日在Facebook开发者区域开了一张票。请添加您的repro,以便获得牵引力。
http://developers.facebook.com/bugs/258628444257212?browse=search_50688f593127e2295697196