让我的朋友列出空数据

时间:2014-10-23 20:24:58

标签: php facebook facebook-graph-api facebook-friends

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

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

0 个答案:

没有答案