开发者

Facebook-PHP-SDK: api('/me') not working, very strange

Here is my code:

    $session = $facebook->getSession();
var_dump($session);/*it says session is perfectly established*/
try {
    $uid = $facebook->getUser();
    echo '<br>';
    var_dump($uid);/*User id is found*/
    $fb_user = $me = $facebook->api('/me');/*PHP execution doesn't go forward, here it breaks*/
    echo '<br>';
    var_dump($fb_user);/*PHP execution doesn't come up to here*/

EDITED: I have print_r the $exception in the catch section and got the following long message:

FacebookApiException Object
(
    [result:protected] => Array
        (
            [error_code] => 6
            [error] => Array
                (
                    [message] => name lookup timed out
                    [type] => CurlException
                )

        )

    [message:protected] => name lookup timed out
    [string:private] => 
    [code:protected] => 6
    [file:protected] => /home/abusadat/public_html/.../facebook.php
    [line:protected] => 614
    [trace:private] => Array
        (
            [0] => Array
                (
                    [file] => /home/abusadat/public_html/.../facebook.php
                    [line] => 575
                    [function] => makeRequest
                    [class] => Facebook
                    [type] => ->
                    [args] => Array
                        (
                            [0] => https://graph.facebook.com/me
                            [1] => Array
                                (
                                    [method] => GET
                                    [access_token] => ******...******
                                )

                        )

                )

            [1] => Array
                (
                    [file] => /home/abusadat/public_html/.../facebook.php
                    [line] => 539
                    [function] => _oauthRequest
                    [class] => Facebook
                    [type] => ->
                    [args] => Array
                        (
                            [0] => https://graph.facebook.com/me
                            [1] => Array
                                (
                                    [method] => GET
                                )

                        )

                )

            [2] => Array
                (
                    [file] => /home/abusadat/public_html/.../facebook.php
                    [line] => 492
                    [function] => _graph
                    [class] => Facebook
                    [type] => ->
                    [args] => Array
                        (
                            [0] => /me
                        )

                )

            [3] => Array
                (
                    [file] => /home/abusadat/public_html/.../fb-connect.php
                    [line] => 31
                    [function] => api
                    [class] => Facebook
                    [type] => ->
                    [args] => Array
                        (
                            [0] => Array
                                (
                                    [0] => Facebook Object
                                        (
                                            [appId:protected] => ******...******
                                            [session:protected] => Array
                                                (
                                                    [access_token] => ******...******
                                                    [base_domain] => abusadat.com
                                                    [expires] => 1312567200
                                                    [secret] => ******...******
                                                    [session_key] => ******...******
                                                    [sig] => ******...******
                                                    [uid] => ******...******
                                                )

                                            [signedRequest:protected] => 
                                            [sessionLoaded:protected] => 1
                                            [cookieSupport:protected] => 1
                                            [baseDomain:protected] =>开发者_运维问答 
                                            [fileUploadSupport:protected] => 
                                        )

                                    [1] => _graph
                                )

                            [1] => Array
                                (
                                    [0] => /me
                                )

                        )

                )

            [4] => Array
                (
                    [file] => /home/abusadat/public_html/.../index.php
                    [line] => 29
                    [args] => Array
                        (
                            [0] => /home/abusadat/public_html/.../fb-connect.php
                        )

                    [function] => include_once
                )

        )

)

I am using SDK version 2.1.2. I have some restriction to use SDK 3 or greater.


My guess is that an exception is being thrown and that you don't see it because your PHP error reporting settings are not tuned properly.

Add this to the top of your PHP file:

ini_set('display_errors', 1);
error_reporting(E_ALL);

You should then see a PHP error when visiting the page.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜