What is the cause of this Facebook error: "An error occurred with PHP SDK Unit Tests"?
I'm working with Facebook login on my website and was looking at this example: https://g开发者_Python百科ithub.com/facebook/php-sdk/blob/master/examples/example.php
When I hit "Login with Facebook" on the example site, I get an error:
An error occurred with PHP SDK Unit Tests. Please try again later.
Any ideas why this would happen?
I was facing the same error earlier (now resolved). The mistake I made was calling Facebook API using old method i.e.
$appid = 'xxx';
$secret = 'xxxxxxxx';
$fb = new Facebook($appid, $secret);
$user = $fb->getUser();
Here $fb instance itself was not correct. I checked it by checking
if ($appid == $fb->geAppId())
TO FIX IT use the new method of API
$appid = 'xxxxxxxx'; // your APP ID
$appsecret = 'xxxxxxxxxx'; // your APP sceret.
$config = array(
'appId'=> $appid, // IMP: note that it is 'appId' and not 'appid'.
'secret' => $appsecret
);
$fb = new Facebook($config);
printf("<br/> FaceBook AppId Test : %s",(($fb->getAppId() == $appid)?"PASSED":"FAILED"));
printf("<br/> FaceBook Secret Test : %s",(($fb->getApiSecret() == $appsecret)?"PASSED":"FAILED"));
Above two printfs are only for testing purpose if $fb itself was created correctly or not. You might want to remove these in your application.
There's a chance that your localhost has issues interfacing with the external servers.
精彩评论