Search code examples
facebookfacebook-fqluserid

I am having problems running Facebook FQL queries that include long user ids


I am having problems running queries with FQL that include a supplied "Large"(beginning with 10000..) User ID

here is an example of one that is not working:

fql?q=SELECT uid, first_name,last_name,pic,pic_square,name 
        FROM user 
        WHERE uid=100002445083370

Is there a way to encapsulate the long number so it's passed as a string?

here is another example:

/fql?q=SELECT src_big 
    FROM photo 
    WHERE aid IN (SELECT aid 
                    FROM album 
                    WHERE  owner=100002445083370 AND type="profile") 
    ORDER BY created DESC LIMIT 1

Has anyone been able to solve this issue? I am testing the queries in the graph explorer with no luck as well.


Solution

  • I see what the problem is,

    The User id I am trying to pass is supposed to be: "100002445083367", but from querying the list of friends and grabbing their User Id, I am getting back "uid":1.0000244508337e+14 which is being shortened to: 100002445083370 (php removing the e+14) throwing off the second query. I need to make sure the id I am grabbing is staying as a string value not a number while I pass it back and forth from PHP and Javascript.

    The problem is because of the way PHP handles JSON_DECODE. I had to modify Facebook PHP SDK and add a preg_replace previous to the json_decode. It will make sure json_decode doesn't convert large integers to floats by first converting them to strings.

    here is the code: line 803 from base_facebook.php:

    $result = json_decode(preg_replace('/("\w+"):(\d+)/', '\\1:"\\2"', $this->_oauthRequest($this->getUrl($domainKey, $path),$params)), true);
    

    here is more information on the subject: http://forum.developers.facebook.net/viewtopic.php?id=20846