1

我正在使用我用来创建 Facebook APP 的 facebook-sdk-master,我无法获取我的朋友列表,我想获取我的朋友列表但它总是返回空数据。
我的代码:

    require '../src/facebook.php';
 echo curlUsingGet('https://graph.facebook.com/me/friends');
function curlUsingGet($url)
    {

   $facebook = new Facebook(array(
  'appId'  => 'app_id',
  'secret' => 'secret_id',
    ));

 $user = $facebook->getUser();
 $access_token =  $facebook->getAccessToken();

 $urlStringData =$url."?access_token=".$access_token ;
    $ch = curl_init();
    $headr = array();
$headr[] = 'GET /v1.0/me HTTP/1.1';
$headr[] = 'Host:graph.facebook.com';
    curl_setopt($ch, CURLOPT_HTTPHEADER,$headr);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,10);
     curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE);
     curl_setopt($ch, CURLOPT_URL, $urlStringData ); #set the url and get string together

     $return = curl_exec($ch);
     curl_close($ch);
     if($return  == false)
     {
         echo 'error:';
     }
     return $return;
     }
4

0 回答 0