0
我是Facebook API的初學者。我剛剛創建的應用程序,我想顯示的姓名和朋友的號碼:Facebook API錯誤致命錯誤:(未捕獲OAuthException:錯誤驗證應用程序)
這是我的代碼:
<?php
require_once 'facebook-php-sdk/src/facebook.php';
$appapikey = '133XXXX60164049';
$appsecret = ' ce6a47dfd838WWWWWW34f387b28633660';
$facebook = new Facebook($appapikey, $appsecret);
$user_id = $facebook->getUser();
$friends = $facebook->api('/me/friends');
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>";
?>
我得到這個
Fatal error: Uncaught OAuthException: Error validating application. Cannot get application info due to a system error. thrown in D:\softs\UwAmp\www\facebook-php-sdk\src\base_facebook.php on line 1238
我想只顯示用戶名如下:
<?php
require_once 'facebook-php-sdk/src/facebook.php';
$appapikey = '453976ergerger647366';
$appsecret = 'fexxxxxxxxeb39bbce717b8062';
$facebook = new Facebook($appapikey, $appsecret);
$user_id = $facebook->getUser();
echo "<p>Hello <fb:name uid=\"$user_id\" useyou=\"false\" linked=\"false\" firstnameonly=\"true\"></fb:name>";
?>
但它不起作用。只有「你好」出現:s
有一些意見,我可以說錯誤發生在這一行: $ friends = $ facebook-> api('/ me/friends'); – Slrg
我試圖添加這個: $ friends = $ facebook-> api_client-> friends_get();但仍然是相同的問題 – Slrg
刪除它,並檢查是否可以顯示$ user_id –