【问题标题】:Uncaught OAuthException未捕获的 OAuthException
【发布时间】:2011-06-22 06:38:42
【问题描述】:

请大家帮我解决这个问题...我的程序给出的错误是“致命错误:未捕获的 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>";

【问题讨论】:

  • 首先我希望您计划尽快重置应用程序的密码,但您似乎使用了一些非常旧的 SDK 示例。您确定那里确实有正确的应用信息,并且该应用存在并且设置正确吗?

标签: php facebook


【解决方案1】:

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

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

【讨论】:

  • bt 连同数组...我什至添加了一个 try - catch 块...正如另一个人的建议...它给了我这个错误:
  • Error:FacebookApiException Object ([result:protected] => Array ([error] => Array ([type] => OAuthException [message] => Invalid OAuth access token signature.)) [message :protected] => 无效的 OAuth 访问令牌签名。[string:private] => [code:protected] => 0 [file:protected] => E:\HostingSpaces\bombil\bombil.com\wwwroot\genderper\src\ facebook.php [line:protected] => 523 [trace:private] => Array ( [0] => Array ( [function] => _graph [class] => Facebook [type] => -> [args] = > 数组 ( [0] => friends.get ) ) [1] => 数组 ( [file] =>
  • E:\HostingSpaces\bombil\bombil.com\wwwroot\genderper\src\facebook.php [line] => 472 [function] => call_user_func_array [args] => Array ([0] => 数组 ( [0] => Facebook 对象 ( [appId:protected] => [apiSecret:protected] => [session:protected] => [signedRequest:protected] => [sessionLoaded:protected] => 1 [cookieSupport :protected] => [baseDomain:protected] => [fileUploadSupport:protected] => ) [1] => _graph ) [1] => 数组 ( [0] => friends.get ) ) [2] =>数组 ( [文件] =>
  • E:\HostingSpaces\bombil\bombil.com\wwwroot\genderper\gender.php [line] => 12 [function] => api [class] => Facebook [type] => - > [args] => 数组 ( [0] => friends.get ) ) ) )
  • 你有SDK的最新版本吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-16
  • 1970-01-01
  • 1970-01-01
  • 2012-07-11
  • 2014-07-30
相关资源
最近更新 更多