$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,我做错了什么吗?
异常,如标题中所述是"发生了未出错",下面是它在 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) "->"
找出异常错误消息是什么。所以做这样的事情:
} 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是一个字符串而不是一个整数。
此外,请确保用户已向应用授予user_photos
权限。 异常错误消息会告诉您。
如果您尝试将照片发布到FB页面,则需要使用页面访问令牌。
您的代码看起来不错,除了我认为'scope'
和'redirect_uri'
不会对图形 API 调用执行任何操作。
我不认为这是你的错。我最近看到了一个非常类似的问题,照片上传失败并显示"发生了未知错误"。这种情况在我们的所有客户帐号中都是随机发生的,但最常见的是两个帐号(80-90% 的上传失败(。有时重试上传可以解决问题,但通常也会失败。
我已经在9/13在Facebook开发者区开了一张票。请添加您的重现,以便它获得牵引力。
http://developers.facebook.com/bugs/258628444257212?browse=search_50688f593127e2295697196