繁体   English   中英

FQL API数组转换有问题吗?

[英]FQL API issues with array translation?

只想知道是否有人遇到过这个问题,我似乎无法解决-大声笑。

使用Facebook fql获取所有用户朋友数据,它会加载90%的UID正确值,然后再加载其他类似“ http://fb.com/1.0000411781126E+14 ”的UID

它正在扩展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>";

使用json_decode()您可以将大整数转换为字符串

只需检查一下。

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

尝试这个

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

在这里回答同样的问题

如何处理FQL返回的big int facebook uid?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM