开发者

Uncaught OAuthException

开发者 https://www.devze.com 2023-03-14 09:23 出处:网络
Guys please help me out with this...the error which my program gives is \"Fatal error: Uncaught OAuthException: Error validating applicatio开发者_C百科n\"...

Guys please help me out with this...the error which my program gives is "Fatal error: Uncaught OAuthException: Error validating applicatio开发者_C百科n"... My program code is :

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>";


You are not creating the Facebook instance correctly. You should use a single parameter (an array) instead of 2 separate parameters. See Facebook PHP SDK example on GIT.

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

精彩评论

暂无评论...
验证码 换一张
取 消