2014-01-05 39 views
0

只是想知道是否有人遇到這個問題,我似乎無法修復它 - 哈哈。陣列轉換的FQL API問題?

使用Facebook FQL讓所有用戶朋友的數據,它加載90%的UID的正確,然後加載其他類似這種「http://fb.com/1.0000411781126E+14

它縮放UID ......但我不是告訴給所有的一切。

代碼:

// run fql query 
    $fql_query_url = 'https://graph.facebook.com/' 
    . 'fql?q=SELECT%20uid%2Cfirst_name%2Clast_name%2Cname%2Cemail%2Ccurrent_location%2Cbirthday_date%2C%20contact_email%2Cusername%20FROM%20user%20WHERE%20uid%20IN%20(SELECT%20uid2%20FROM%20friend%20WHERE%20uid1%20%3D%20me())%0A' 
    . '&access_token=' . $access_token; 
    $fql_query_result = file_get_contents($fql_query_url); 
    $fql_query_obj = json_decode($fql_query_result, true); 

    // display results of fql query 
// echo '<pre>'; 
    //print_r("query results:"); 
    //print_r($fql_query_obj); 
    //echo '</pre>'; 

?> 

<table class="dynamicTable colVis table table-striped table-bordered table-condensed table-white"> 
     <thead> 
     <tr> 
      <th>Image</th> 
      <th>Full Name</th> 
      <th>Gender</th> 
      <th>Locale</th> 
      <th>FB Email</th> 
      <th>Location</th> 
      <!-- <th>Job</th> --> 
      <th>Subscribers</th> 
      <th>SubscribedTo</th> 
      <th>Groups</th> 
      <th>Posts</th> 
     </tr> 
     </thead> 

     <?php 
     $loopvar = 1; 
     foreach ($fql_query_obj['data'] as $eachfriend) { 
      $id  = $eachfriend['uid']; 
      $name  = $eachfriend['name']; 
      $username = $eachfriend['username']; 

      //if(array_key_exists('work', $eachfriend)){ 
      // $current_work = $eachfriend['work'][0]['employer']['name']; 
      //} 
      // else 
      // $current_work = "<span style='color:red;'>None</span>"; 



     echo "<tr>"; 
     echo "<td><a target='_blank' href='http://fb.com/".$id."'><img src='http://graph.facebook.com/" . $id . "/picture'/></a></td>"; 
     // echo "<td><a target='_blank' href='http://fb.com/".$id."'>" . $id . "</a></td>"; 
     echo "<td>" . $name . "</td>"; 
+0

剛剛意識到我的英語是太可怕了這裏,洛爾 - 即使我加拿大人。猜猜這是在凌晨4點發生的事情:) –

回答

0

試試這個

$fql_query_obj = json_decode(preg_replace('/"uid":(\d+)/', '"uid":"$1"', $fql_query_result),true); 

這裏回答同樣的問題

How to handle the big int facebook uid returned by FQL?

+1

我會接受你的答案,但下面的一個也工作得很好!再次感謝。 –

0

使用json_decode()您可以將大整數轉換爲字符串

這個只是檢查。

$fql_query_obj = json_decode($fql_query_result, true, 512, JSON_BIGINT_AS_STRING) 
+1

這很好用!感謝您的意見。 –

+0

@ user3109966你也可以Up-Vote如果這真的對你有用。謝謝.. :) –

+1

沒有足夠的代表或什麼..大聲笑必須有15 –