Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7583101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:36:07+00:00 2026-05-30T18:36:07+00:00

I’ve a problem in handling the big userid’s of facebook and properly storing them

  • 0

I’ve a problem in handling the big userid’s of facebook and properly storing them into my database..

As the fql.query REST api is going to be deprecated ,I’m using the GRAPH API for getting the results of the FQL.

I want to get the list of my friends with sex,relationship_status .

The query i executed is

$allFriends = $facebook->api("/fql
    ?q=SELECT+uid,+name,+sex,+relationship_status+FROM+user+where+uid+in+
    (SELECT+uid2+FROM+friend+WHERE+uid1+=$fbuid)"
);

I tried the above in the Graph API explorer and the result is something like this,

  {
  "data": [
     {
      "uid": 100003082853071, 
      "name": "Sam jones", 
      "sex": "male", 
      "relationship_status": null
     }  
   ]
  }

Note the uid is returned as int, so whenever i print the array itself it has values like (1.34234422 +E03). So even json_encode for that array doesn’t help.

But when i call the GRAPH API directly something like ‘graph.facebook.com/1585213/friends‘ that returns the data as

{
  "data": [
    {
      "name": "Vijay Kannan", 
      "id": "102937142343"
    }
  ]  
}

Note the id is returned as string..

Whenever I’m using the graph API call for FQL query, it returns the whole data as an ‘Array‘ ,so the long big facebook uid’s are transformed to a float like (1.34234422 +E03) .

How can i convert them into proper uid’s and store/process them back.

I think the inconsistency of FQL and GRAPH API call should be also taken care by Facebook .. But i could not wait for that!!

Any ideas on this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T18:36:09+00:00Added an answer on May 30, 2026 at 6:36 pm

    I tried most methods and after Google some more forums and facebook code list if found the following worked like a charm for me.

    After i get the results from a FQL query i used the following line of code,

    $friends = json_decode(preg_replace('/"uid":(\d+)/', '"uid":"$1"', $result),true); 
    // consider $result as the result rendered by the FQL query.
    

    When i use the file_get_contents for a FB call you could have seen the error with error codes, so the best way to go with that is using CURL for all the FB API calls whenever necessary.

    Please find the complete code i’ve used to get proper results,

    $access_token = $facebook->getAccessToken();
    $request_url ="https://graph.facebook.com/fql
                   ?q=SELECT+uid,+name,+sex+FROM+user+where+uid+in+
                   (SELECT+uid2+FROM+friend+WHERE+uid1+=$fbuid)".
                   "&access_token=".$access_token;
    
    $opts = array(
                CURLOPT_CONNECTTIMEOUT => 10,
                CURLOPT_RETURNTRANSFER => true,
                CURLOPT_TIMEOUT        => 60,
                CURLOPT_USERAGENT      => 'facebook-php-3.1',
                CURLOPT_CAINFO         => /lib/fb_ca_chain_bundle.crt',
               //replace the above path with proper path of the crt file 
               //in order to avoid the exceptions rendered by FB 
               //when we try to use CURL without proper certification file.
        );
    
    $opts[CURLOPT_URL] = $request_url;
    
    if (isset($opts[CURLOPT_HTTPHEADER])) {
            $existing_headers = $opts[CURLOPT_HTTPHEADER];
            $existing_headers[] = 'Expect:';
            $opts[CURLOPT_HTTPHEADER] = $existing_headers;
    } else {
            $opts[CURLOPT_HTTPHEADER] = array('Expect:');
    }
    
    $ch = curl_init();
    curl_setopt_array($ch, $opts);
    $result = curl_exec($ch);
    
    if ($result === false) {
          $e = new FacebookApiException(array(
            'error_code' => curl_errno($ch),
            'error' => array(
            'message' => curl_error($ch),
            'type' => 'CurlException',
            ),
          ));
          curl_close($ch);
          throw $e;
    }
    
    curl_close($ch);
    $friends = json_decode(preg_replace('/"uid":(\d+)/','"uid":"$1"',$result));
    

    I just to post this answers so it may help others until Facebook resolve this inconsistency.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I am currently running into a problem where an element is coming back from
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I've tracked down a weird MySQL problem to the two different ways I was
I have an array which has BIG numbers and small numbers in it. I
I have been unable to fix a problem with Java Unicode and encoding. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.