简体   繁体   English

上手OAuthException:将照片发布到目标相册后发生未知错误

[英]Getting Uncaught OAuthException: An unknown error has occurred on photo post to target album

$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');
    }

And it still redirects to somethingwentwrong.com, am I doing something wrong? 而且它仍然重定向到somethingwentwrong.com,我做错什么了吗?

The exception, as stated in the title is "An unknwon error has occured", here's the object it returnes in the catch statement: 如标题中所述,“发生了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) "->"

Find out what the exception error message is. 找出什么是异常错误消息。 So do something like this: 所以做这样的事情:

} catch {
  error_log('caught exception: '. $e);
  header('location:http://www.somethingwentwrong.com');
}

If you get OAuthException: (#803) Some of the aliases you requested do not exist then make sure $album_uid is a string and not an int. 如果您收到OAuthException: (#803) Some of the aliases you requested do not exist确保$ album_uid是字符串而不是int。

Also make sure the user has given your app the user_photos permission. 另外,请确保用户已为您的应用user_photos权限。 The exception error message will tell you. 异常错误消息将告诉您。

If you are trying to post a photo to an FB Page, you need to use a Page Access Token. 如果尝试将照片发布到FB页面,则需要使用页面访问令牌。

Your code looks ok, except I think 'scope' and 'redirect_uri' won't do anything to the Graph API call. 您的代码看起来还不错,除了我认为'scope''redirect_uri'对Graph API调用没有任何作用。

I don't think this is your fault. 我不认为这是你的错。 I've been seeing a very similar issue lately, photo uploads are failing with "an unknown error has occurred". 我最近看到了一个非常相似的问题,照片上传失败并显示“发生未知错误”。 This is happening randomly across all of our client accounts, but most frequently on two accounts (80-90% of uploads fail). 这是在我们所有客户帐户中随机发生的,但最常见的是在两个帐户中发生(80-90%的上传失败)。 Sometimes retrying the upload will solve the problem but it usually fails as well. 有时重试上传可以解决问题,但通常也失败。

I've opened a ticket on Facebook Developers area on 9/13. 我已经在9/13在Facebook Developers区域打开了一张票。 Please add your repro so it gains traction. 请添加您的复制品,以增加吸引力。

http://developers.facebook.com/bugs/258628444257212?browse=search_50688f593127e2295697196 http://developers.facebook.com/bugs/258628444257212?browse=search_50688f593127e2295697196

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Facebook-创建事件给出“未捕获的OAuthException:发生未知错误” - Facebook - Creating event gives “Uncaught OAuthException: An unknown error has occurred” 未捕获OAuthException:Facebook PHP API出现未知错误 - Uncaught OAuthException: An unknown error has occurred with Facebook PHP API 致命错误:未捕获的OAuthException:发生意外错误。 请稍后重试您的请求 - Fatal error: Uncaught OAuthException: An unexpected error has occurred. Please retry your request later OAuthException:发生意外错误-更改应用程序名称空间后 - OAuthException: An unexpected error has occurred - after changing app namespace 未捕获的OAuthException错误 - Uncaught OAuthException error 未捕获的OAuthException:验证应用程序时出错 - Uncaught OAuthException: Error validating application 未捕获的OAuthException - 如何捕获此错误? - Uncaught OAuthException - how to catch this error? FB开发人员:未捕获的OAuthException:(#120)无效的相册ID - FB Developer: Uncaught OAuthException: (#120) Invalid album id Uncaught OAuthException: (#200),当试图在墙上发帖时 - Uncaught OAuthException: (#200), when trying to post on wall 未捕获的异常:1:在Facebook API中引发了未知错误,FQL错误 - Uncaught exception: 1: An unknown error occurred thrown in Facebook API, FQL error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM