【问题标题】:stdClass Object ( [error] => stdClass Object ( [type] => OAuthException [message] => Error validating application. ) )stdClass 对象([error] => stdClass 对象([type] => OAuthException [message] => 验证应用程序时出错。))
【发布时间】:2011-09-07 19:55:40
【问题描述】:

我验证了我的 appid、appsecret 是正确的,并且我的 access_token 是正确且有效的。我仍然收到“验证应用程序错误”。错误信息。有谁知道为什么会这样?

<?php

define('YOUR_APP_ID', 'x');
define('YOUR_APP_SECRET', 'x');

function get_facebook_cookie($app_id, $app_secret) {
  $args = array();
  parse_str(trim($_COOKIE['fbs_' . $app_id], '\\"'), $args);
  ksort($args);
  $payload = '';
  foreach ($args as $key => $value) {
    if ($key != 'sig') {
      $payload .= $key . '=' . $value;
    }
  }
  if (md5($payload . $app_secret) != $args['sig']) {
    return null;
  }
  return $args;
}

$cookie = get_facebook_cookie(YOUR_APP_ID, YOUR_APP_SECRET);

$access_token="AAADDMjYCsTABAAbzGa3vLtSq7rt4iZBmnuFXUDRVxVnZAm8HbQp2chBBUIfJpAADiJWOu5TIPr0tnnKDhLEbXCicqLl8sP6KFT1vb8ZCkz6PeuUMUIs";
$url = 'https://graph.facebook.com/me?access_token=' . $access_token;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
curl_close($ch);

$user = json_decode($response);
print_r($user);

?>
<html>
  <body>
    <?php if ($cookie) { ?>
      Welcome <?php  ?>
    <?php } else { ?>
      <fb:login-button></fb:login-button>
    <?php } ?>
    <div id="fb-root"></div>
    <script src="http://connect.facebook.net/en_US/all.js"></script>
    <script>
      FB.init({appId: '<?= YOUR_APP_ID ?>', status: true,
               cookie: true, xfbml: true});
      FB.Event.subscribe('auth.login', function(response) {
        window.location.reload();
      });
    </script>
  </body>
</html>

【问题讨论】:

    标签: php facebook request signed


    【解决方案1】:

    我建议您对 appid 和 appsecret 保密。请勿在此类网站上发布。

    【讨论】:

      猜你喜欢
      • 2011-08-31
      • 1970-01-01
      • 2015-12-13
      • 1970-01-01
      • 2013-06-23
      • 2021-01-19
      • 2015-06-12
      • 2012-01-19
      • 2010-12-06
      相关资源
      最近更新 更多