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

有些话、适合烂在心里 提交于 2019-12-08 07:06:45

问题


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:


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; 
}


来源:https://stackoverflow.com/questions/18693369/facebook-api-me-raises-curlexception-3-no-url-set

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!