Facebook->api(“/me”) raises “CurlException: 3: No

2019-06-06 13:02发布

I have an iframe page tab facebook app that, for some users on some pages, raises a "CurlException: 3: No URL set!" exception when calling $facebook->api("/me").

Here is the code :

$config = array();
$config['appId'] = APPID;
$config['secret'] = APPSECRET;
$config['cookie'] = true;
$config['fileUpload'] = false; // optional

$facebook = new Facebook($config);

$facebook->setExtendedAccessToken();

$access_token = $facebook->getAccessToken();

if (isset($_GET['tk'])&&($_GET['tk']!="")){
$_SESSION['appat'] = $_GET['tk'];
}

if ($_SESSION['appat']!="")
$access_token = $_SESSION['appat'];

$facebook->setAccessToken($access_token);       

$user = $facebook->getUser();

if ($user) {
    try {
        $user_profile = $facebook->api('/me');
    } catch (FacebookApiException $e) {
        trace("exception $e");
    }
}

NOTE : The access token is given by the Javascript sdk as a GET variable as received on the app home page and I store it into a session variable for further uses.

1条回答
虎瘦雄心在
2楼-- · 2019-06-06 13:26

by problems with IPV6 you should have included the following line in your facebook api.

Facebook::$CURL_OPTS[CURLOPT_IPRESOLVE] = CURL_IPRESOLVE_V4;

however this alternative only works with version 5.3 of php largest

solution:

if((phpversion()>= 5.3))
{ 
   Facebook::$CURL_OPTS[CURLOPT_IPRESOLVE] = CURL_IPRESOLVE_V4; 
}
查看更多
登录 后发表回答