作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
$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 是一个字符串而不是一个 int。
还要确保用户已授予您的应用 user_photos
权限。异常错误信息会告诉你。
如果您尝试将照片发布到 FB 页面,则需要使用页面访问 token 。
你的代码看起来不错,除了我认为 'scope'
和 'redirect_uri'
不会对 Graph API 调用做任何事情。
关于php - 获取未捕获的 OAuthException : An unknown error has occurred on photo post to target album,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12384877/
我是一名优秀的程序员,十分优秀!