PHP-如何从FacebookApiException $e获取代码ID?
作者:互联网
如何从FacebookApiException $e获取代码ID?
我正在使用Facebook发布.但有时无法发布内容.我在下面使用这些代码,并且在数组$e中找到了错误响应代码ID,但所有代码都受到保护,那么我如何获取代码?
try{
$facebook->setAccessToken($access_token);
$rs= $facebook->api('/me/feed','POST',$post_data);
} catch (FacebookApiException $e) {
print_r($e);
}
然后我得到错误信息:
FacebookApiException Object
(
[result:protected] => Array
(
[error] => Array
(
[message] => Invalid OAuth access token.
[type] => OAuthException
[code] => 190 // I need this code
)
)
[message:protected] => Invalid OAuth access token.
[string:private] =>
[code:protected] => 0
[file:protected] => D:\phpnow\htdocs\laji\facebook-php-sdk\base_facebook.php
[line:protected] => 1267
[trace:private] => Array
(
[0] => Array
(
[file] => D:\phpnow\htdocs\laji\facebook-php-sdk\base_facebook.php
[line] => 876
[function] => throwAPIException
[class] => BaseFacebook
[type] => ->
[args] => Array
(
[0] => Array
(
[error] => Array
(
[message] => Invalid OAuth access token.
[type] => OAuthException
[code] => 190
)
)
)
)
[1] => Array
(
[file] => D:\phpnow\htdocs\laji\facebook-php-sdk\base_facebook.php
[line] => 650
[function] => _graph
[class] => BaseFacebook
[type] => ->
[args] => Array
(
[0] => /me/feed
[1] => POST
[2] => Array
(
[access_token] => 1CAACg13jYHp8BAP0QEOK8PwC7ZCMnSa1tAQclbRJpcNP1zQIBnB1to6etQ2wb8wiVcETDvT5dRZAUiNiZBFvt1RYgo5xUe1do4yeY5DxKIjjDBbElI8zZBBlz5yHRwigIcNYtyhHY9ZAtHL16ZAMPyo43wZANhGWE6o6EV7hXZBtxBEN24xTlGa7M
[picture] => http://imgjy.com/FPB470/m/5236e26acc73a.jpg
[link] => http://www.persunmall.com/persun/giveaway02.html?refer_id=1900
[name] => my all_prams link <name>7458
)
)
)
[2] => Array
(
[file] => D:\phpnow\htdocs\laji\fb_post.php
[line] => 98
[function] => api
[class] => BaseFacebook
[type] => ->
[args] => Array
(
[0] => Array
(
[0] => Facebook Object
(
[sharedSessionID:protected] =>
[appId:protected] => 176847305842335
[appSecret:protected] => f79311ddff5888a165d46159b06f4670
[user:protected] =>
[signedRequest:protected] =>
[state:protected] =>
[accessToken:protected] =>
[fileUploadSupport:protected] =>
[trustForwarded:protected] =>
)
[1] => _graph
)
[1] => Array
(
[0] => /me/feed
[1] => POST
[2] => Array
(
[access_token] => 1CAACg13jYHp8BAP0QEOK8PwC7ZCMnSa1tAQclbRJpcNP1zQIBnB1to6etQ2wb8wiVcETDvT5dRZAUiNiZBFvt1RYgo5xUe1do4yeY5DxKIjjDBbElI8zZBBlz5yHRwigIcNYtyhHY9ZAtHL16ZAMPyo43wZANhGWE6o6EV7hXZBtxBEN24xTlGa7M
[picture] => http://imgjy.com/FPB470/m/5236e26acc73a.jpg
[link] => http://www.persunmall.com/persun/giveaway02.html?refer_id=1900
[name] => my all_prams link <name>7458
)
)
)
)
)
)
解决方法:
如果没有尝试过,这行不通吗?
echo "Code: " . $e["error"]["code"];
标签:php,facebook,facebook-php-sdk 来源: https://codeday.me/bug/20191010/1884343.html