title: Facebook graph extremely slow in PHP
body: <p>Whether using the Facebook PHP SDK, or just loading data using curl with <code>$contents = file_get_contents("https://graph.facebook.com/$id?access_token=$accessToken")</code>, it takes around a whole second for the response to come.</p>
  
  <p>That counts as very slow when I need to check the data for a bunch of ids.</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>IDEA: perhaps I need to configure something in cURL?</p>
  
  <p>What I have tried:</p>
  
  <ul>
  <li>Using the PHP SDK. It's as slow. The reason I tried using <code>file_get_contents()</code> in the first place was because I was hoping the PHP SDK wasn't configured properly.</li>
  <li>Using <code>setopt($ch, CURLOPT_SSL_VERIFYPEER, false);</code>. It didn't make a difference. AFTER ANSWER ACCEPT EDIT: actually, this together with reusing the curl handle made the subsequent requests really fast.</li>
  </ul>
  
  <p>EDIT: here is a pastebin of the code I used to measure the time it takes to do the requests: <a href="http://pastebin.com/bEbuqq5g" rel="nofollow noreferrer">http://pastebin.com/bEbuqq5g</a>.
  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: <a href="https://stackoverflow.com/questions/11412406/facebook-graph-extremely-slow-in-php#comment16127892_12073498">Facebook graph extremely slow in PHP</a>. Note also that they take similarly slow times even if the access token is expired, like in my pastebin example.</p>
  
  <p>EDIT 2: there should be partly a problem with ssl. I tried benchmarking <a href="http://graph.facebook.com/4" rel="nofollow noreferrer">http://graph.facebook.com/4</a> (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.</p>