我如何从FacebookApiException $ e获取代码ID? [英] how can i get the code id from FacebookApiException $e?

查看:60
本文介绍了我如何从FacebookApiException $ e获取代码ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从FacebookApiException $e获取代码ID?

我正在使用Facebook进行发布.但有时无法发布内容.我在下面使用这些代码,并且在数组$e中找到了错误响应代码ID,但是所有代码都受到保护,那么如何获取代码?

I am using Facebook to post. but sometimes it fails to post the content. I am using these codes below, and I find the error response code id in array $e, but all them are protected, how can i get the code then?

try{
    $facebook->setAccessToken($access_token);
    $rs= $facebook->api('/me/feed','POST',$post_data);
} catch (FacebookApiException $e) {
    print_r($e);
}

然后我得到了错误信息:

then I get the error info:

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
                                        )

                                )

                        )

                )

        )

)

推荐答案

如果没有尝试过,这行不通吗?

Without having tried it, wouldn't this work?

echo "Code: " . $e["error"]["code"];

这篇关于我如何从FacebookApiException $ e获取代码ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆