I’m using the following code to retrieve a user’s friends:
$fql_query_url = 'https://graph.facebook.com/fql?q=SELECT+uid,+name,+pic_square+FROM+user+WHERE+uid+IN+(SELECT+uid2+FROM+friend+WHERE+uid1+=+me())+order+by+name&access_token=' . $_SESSION['token'];
$fql_query_result = file_get_contents($fql_query_url);
$fql_query_obj = json_decode($fql_query_result, true);
It works just fine except that for any Facebook IDs that are more than 11 numbers long, they get rendered as 1.xxxxxxxxxxxxxE+14 instead of 1xxxxxxxxxxxxxx. (ex: 100000776800425 instead becomes 1.0000077680042E+14). This wouldn’t be a problem except that the last digit gets lost.
Annoyingly, if I plug in the query URL in the address bar, the IDs don’t get changed. The IDs don’t get changed either if I query for “SELECT uid2 FROM friend WHERE uid1 = me()”.
What is causing this and how do I get around it? Thanks.
Edit:
I’ve at least managed to determine that the values get changed during json_decode but other than that, nothing.
Edit 2:
Adding ini_set(‘precision’, 20) solved it.
php settings cause the value to be converted to an int, which lacks the necessary length to properly display longer Facebook IDs. Adding ini_set(‘precision’, 20) at the start of the script increased the precision to 20 digits.