We have an app running on a Facebook tab at the moment which is receiving a good deal of traffic. People are signing up every few seconds, and most are successful. However I
Update: After modifying my code to use curl, there was some improvement, but it did not resolve the issue. The application in question is now past its peak usage, so obviously the number of errors have gone down drastically. It still happens sometimes. The errors are (most often):
...and other similar errors.
From my experience with a week or two of data, it seems to effect about a percent of requests when there is high traffic, less when there is low - but this is quite unscientific. :)
--
So the solution? Well there is none really. It seems that some percent of requests will fail and my (your) application needs to handle these errors as elegantly as possible.
My only question is, has anyone else had such experience with high traffic apps? (meaning in this case 100 000-500 000 daily pageviews and 50 000-100 000 active users)
I think it's because php_openssl
extension is either absent or disabled. See this question to enable it. Or you can use cURL. Take fb_ca_chain_bundle.crt
from PHP SDK official (or set CURLOPT_SSL_VERIFYPEER
to false
):
$base_url = 'https://graph.facebook.com/oauth/access_token';
$params = array();
$params['client_id'] = $client_id;
$params['client_secret'] = $client_secret;
$params['redirect_uri'] = $redirect_uri;
$params['code'] = $code;
$options = array(
CURLOPT_SSL_VERIFYHOST => 2,
CURLOPT_SSL_VERIFYPEER => true,
CURLOPT_CAINFO => __DIR__ .'/fb_ca_chain_bundle.crt',
CURLOPT_RETURNTRANSFER => true,
CURLINFO_HEADER_OUT => false,
CURLOPT_HEADER => false,
CURLOPT_URL => $base_url . '?' . http_build_query($params),
);
// Init cURL and send the request
$ch = curl_init();
curl_setopt_array($ch, $params);
$result = curl_exec($ch);
$infos = curl_getinfo($ch);
curl_close($ch);
var_dump($result, $infos);
EDIT: i warn you this is a quick copy and paste from my code so you would double check $options
.
Try to log the curl error and return value when you obtain the access_token the answer should be there.