未捕获的OAuthException

时间:2011-06-22 06:38:43

标签: php facebook

伙计们请帮帮我...我的程序给出的错误是“致命错误:未捕获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>";

1 个答案:

答案 0 :(得分:1)

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

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