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 8447315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:09:14+00:00 2026-06-10T10:09:14+00:00

Whether using the Facebook PHP SDK, or just loading data using curl with $contents

  • 0

Whether using the Facebook PHP SDK, or just loading data using curl with $contents = file_get_contents("https://graph.facebook.com/$id?access_token=$accessToken"), it takes around a whole second for the response to come.

That counts as very slow when I need to check the data for a bunch of ids.

When in a browser, if I type in a facebook graph url, I get the results almost instantly, under a tenth of the time it takes in PHP.

What is causing this problem, and how can I make it as fast as it would be in any browser? I know the browser can do it. There has to be a way to make it fast in PHP too.

IDEA: perhaps I need to configure something in cURL?

What I have tried:

  • Using the PHP SDK. It’s as slow. The reason I tried using file_get_contents() in the first place was because I was hoping the PHP SDK wasn’t configured properly.
  • Using setopt($ch, CURLOPT_SSL_VERIFYPEER, false);. It didn’t make a difference. AFTER ANSWER ACCEPT EDIT: actually, this together with reusing the curl handle made the subsequent requests really fast.

EDIT: here is a pastebin of the code I used to measure the time it takes to do the requests: http://pastebin.com/bEbuqq5g.
I corrected the text that used to say microseconds, to seconds. this is what produces results similar to the one I wrote in my comment in this question: Facebook graph extremely slow in PHP. Note also that they take similarly slow times even if the access token is expired, like in my pastebin example.

EDIT 2: there should be partly a problem with ssl. I tried benchmarking http://graph.facebook.com/4 (no httpS), and it resulted in 1.2 seconds for three requests, whereas the same, but with https took 2.2 seconds. This is in no way a solution though, because for any request that needs an access token, I must use https.

  • 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-06-10T10:09:15+00:00Added an answer on June 10, 2026 at 10:09 am

    I wondered what would happen if I did two subsequent curl_exec() calls without doing a curl_close(), enabling the use of HTTP Keep-Alive.

    The test code:

    $ch = curl_init('https://graph.facebook.com/xxx');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    
    // FIRST REQUEST
    curl_exec($ch);
    print_r(curl_getinfo($ch));
    
    // SECOND REQUEST
    curl_exec($ch);
    print_r(curl_getinfo($ch));
    
    curl_close($ch);
    

    Below are the results, showing parts of the output from curl_getinfo():

    // FIRST REQUEST
    [total_time] => 0.976259
    [namelookup_time] => 0.008271
    [connect_time] => 0.208543
    [pretransfer_time] => 0.715296
    
    // SECOND REQUEST
    [total_time] => 0.253083
    [namelookup_time] => 3.7E-5
    [connect_time] => 3.7E-5
    [pretransfer_time] => 3.9E-5
    

    The first request is pretty slow, almost one whole second, similar to your experience. But from the time of the second request (only 0.25s) you can see how much difference the keep-alive made.

    Your browser uses this technique as well of course, loading the page in a fresh instance of your browser would take considerably longer.

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

Sidebar

Related Questions

I'm using v3 of both the JS SDK and PHP SDK for Facebook Connect.
I am using Facebook PHP SDK to authenticate the user. After generating the LoginUrl
REVISED QUESTION I realize using the response to: $facebook->api('/me?access_token='.$access_token) will determine whether you need
So I am using the facebook-php-sdk and I have created a page tab On
I'm developing using the Facebook PHP SDK. I wanted to make it so that
I need to send Message using Facebook Graph Api. I found this article http://developers.facebook.com/docs/reference/api/message/
I am using Facebook Javascript SDK http://developers.facebook.com/docs/reference/javascript/ to authenticate and approve my Facebook app.
I am struggling to keep the Facebook session alive using PHP on my website.
I am using the PHP SDK Version 3.1.1 in order to make a simple
I am using the Facebook SDK to be able to make a Facebook login

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.