2011-06-22 96 views
0

家伙请帮我这...这我的程序给错误是“致命错误:未捕获OAuthException:错误校验应用程序” ...... 我的程序代码是:未捕获OAuthException

require ("src/facebook.php"); 

$appapikey = 'xxx'; 
$appsecret = 'xxx'; 

$facebook = new Facebook($appapikey, $appsecret); 

$user_id = $facebook->getUser(); 

$friends = $facebook->api('friends.get'); 



echo "<p>Hello <fb:name uid=\"$user_id\" useyou=\"false\" linked=\"false\" firstnameonly=\"true\"></fb:name>, you have ".count($friends)." friends"; 

foreach($friends as $friend){ 
    $infos.=$friend.","; 
} 

$infos = substr($infos,0,strlen($infos)-1); 

$gender=$facebook->api_client->users_getInfo($infos,'sex'); 

$gender_array = array(); 

foreach($gender as $gendervalue){ 
    $gender_array[$gendervalue[sex]]++; 
} 

$male = round($gender_array[male]*100/($gender_array[male]+$gender_array[female]),2); 
$female = 100-$male; 

echo "<ul><li>Males: $male%</li><li>Females: $female%</li></ul>"; 
+0

那么首先我倒是希望你打算很快重置您的应用程序的秘密,但你似乎可以用一些很老的SDK样本。你确定你确实有正确的应用程序信息,并且该应用程序存在并且设置正确吗? – Yuliy

回答

1

你没有正确创建Facebook实例。您应该使用单个参数(数组)而不是2个单独的参数。请参阅GIT上的Facebook PHP SDK example

$facebook = new Facebook(array(
    'appId' => $appapikey, 
    'secret' => $appsecret, 
)); 
+0

感谢您的帮助:) –

+0

与阵列一起bt ...我甚至添加了一个try-catch块...正如另一个人所建议的那样...它给我这个错误: –

+0

错误:FacebookApiException对象([result: )] []:> Array [(error] => Array([type] => OAuthException [message] =>无效的OAuth访问令牌签名。 => [code:protected] => 0 [file:protected] => E:\ HostingSpaces \ bombil \ bombil.com \ wwwroot \ genderper \ src \ facebook.php [line:protected] => 523 [trace:private] =>数组([0] =>数组([函数] => _graph [class] => Facebook [type] => - > [args] => Array([0] => friends.get)[1] => Array([file] => –

相关问题