我的FQL为UID返回非法字符。这是我的FQL。 select uid,books from user where uid in (select uid2 from friend where uid1=me())
。我正在使用PHP SDK,我正在获取像1.0000008018280E+14
这样的ID(两者之间有'E'in)。我总共600个联系人中的大约400个显示UID。我尝试指向facebook.com/1.0000008018280E+14
,返回 304页面未找到错误。我正在使用的代码是
$fql_query_url = 'https://graph.facebook.com/'.'fql?q=select+uid,books+from+user+where+uid+in(select+uid2+from+friend+where+uid1=me())'.'&access_token='.$_GET['access'];
$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($fql_query_obj);
echo '</pre>';
答案 0 :(得分:1)
根据How to get around or make PHP json_decode not alter my very large integer values?,您可以这样做:
<?php
$fql_query_url = 'https://graph.facebook.com/'.'fql?q=select+uid,books+from+user+where+uid+in(select+uid2+from+friend+where+uid1=me())'.'&access_token='.$_GET['access'];
$fql_query_result = file_get_contents($fql_query_url);
$fql_query_result = preg_replace('/:\s*(\-?\d+(\.\d+)?([e|E][\-|\+]\d+)?)/', ': "$1"', $fql_query_result);
$fql_query_obj = json_decode($fql_query_result, true);
echo '<pre>';
print_r($fql_query_obj);
echo '</pre>';
?>
或,如Handling big user IDs returned by FQL in PHP
所示<?php
$fql_query_url = 'https://graph.facebook.com/'.'fql?q=select+uid,books+from+user+where+uid+in(select+uid2+from+friend+where+uid1=me())'.'&access_token='.$_GET['access'];
$fql_query_result = file_get_contents($fql_query_url);
$fql_query_obj = json_decode(preg_replace('/("\w+"):(\d+)/', '\\1:"\\2"', $fql_query_result), true);
echo '<pre>';
print_r($fql_query_obj);
echo '</pre>';
?>