Php 无法从graph API检索任何数据

Php 无法从graph API检索任何数据,php,facebook-graph-api,Php,Facebook Graph Api,您好,我正在使用下面的代码部分。在后台,上次工作时,由于ssl相关问题,我得到了Curl异常77。我的域中仍然没有启用HTTPS。有了这些信息。我正在粘贴下面的代码部分。我正在使用一些打印件进行调试。(我是PHP新手,请耐心等待) 有机会看到真实的错误消息吗?是的。这是消息:SSL CA证书有问题(路径?访问权限?[type]=>CurlException)(我只是从我的浏览器历史记录中找到的…所以只有这一部分..但我猜这足以说明问题)我的错误1:PHP-SDK 3.X没有getSession

您好,我正在使用下面的代码部分。在后台,上次工作时,由于ssl相关问题,我得到了Curl异常77。我的域中仍然没有启用HTTPS。有了这些信息。我正在粘贴下面的代码部分。我正在使用一些打印件进行调试。(我是PHP新手,请耐心等待)



有机会看到真实的错误消息吗?是的。这是消息:SSL CA证书有问题(路径?访问权限?[type]=>CurlException)(我只是从我的浏览器历史记录中找到的…所以只有这一部分..但我猜这足以说明问题)我的错误1:PHP-SDK 3.X没有getSession函数。刚刚意识到。这就是为什么人们不应该复制粘贴代码。情况只会变得更糟(重温一节课。
<?php
    include_once('./php-sdk/facebook.php');
    include_once('./php-sdk/fbhelper.php');

    $config = array(
        'appId' => FACEBOOK_APP_ID,
        'secret' => FACEBOOK_SECRET,
    );

    try {
        $facebook = new Facebook($config);
    }
    catch (FacebookApiException $e) {
        echo 'Excetption is' . $e->__toString();
    }
?>

<?php

    $user_id = $facebook->getUser();

    if ($user_id) {
        echo "user exists and is: " .$user_id;
    } else {
        echo "user DONT exists";
    }

    // If i comment out this next try catch block for $session, then my page renders
    // fine, but when I am using this code block, then my page doesn't render beyond 
    // this code section. This is very strange. Why not an exception is thrown if there
    // are any issues? Can anybody help me understand this?

    try {
        $session = $facebook->getSession();

        if ($session) {
            echo "user exists and is: " . $session;
        } else {
            echo "user DONT exists";
        }
    } catch (FacebookApiException $e) {
        print_r($e);
    }

    // now when I comment out above $session related part, then page renders fine, but 
    // no where any prints show me anything. Why the name is not getting reflected?
    if ($user_id) {
        try {
            $user_profile = $facebook->api('/727850431', 'GET');
            echo 'Name: ' . $user_profile['name'];
        } catch (FacebookApiException $e) {
            print_r($e);
            $login_url = $facebook->getLoginUrl();
            echo 'Please <a href="' . $login_url . '">login.</a>';
        }
    } else {
        $login_url = $facebook->getLoginUrl();
        echo 'Please <a href="' . $login_url . '">login.</a>';
    }

    try {
        $url = 'https://graph.facebook.com/oauth/access_token?client_id=FACEBOOK_APP_ID&client_secret=FACEBOOK_SECRET& grant_type=client_credentials';
        $app_access_token = json_decode(file_get_contents($url));

        $graph_url = "https://graph.facebook.com/me?access_token=" . $app_access_token;
        $result = json_decode(file_get_contents($graph_url));
        print_r($result);
    } catch (FacebookApiException $e) {
        print_r($e);
    }

?>