Facebook应用程序连接不起作用

时间:2014-04-17 19:46:42

标签: php facebook api facebook-graph-api facebook-opengraph

我登录Facebook应用程序时遇到问题。 当我点击“登录”时,我被重定向到Facebook接受权限,然后Facebook重定向我。但它没有改变任何东西。 URL向下是动态生成的。当我在另一个不是动态的URL上尝试相同的脚本时,它会起作用。

这是我尝试执行登录的URL。 http://www.testaiq.se/test_592.html

可能是什么问题? PHP落后URL

require_once("facebook/facebook.php");

// Creating our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
  'appId'  => 'XXX',
  'secret' => 'XXX',
));

// Getting User ID
$user = $facebook->getUser();

// Get Access token
$access_token = $facebook->getAccessToken();

// We may or may not have this data based on whether the user is logged in.
//
// If we have a $user id here, it means we know the user is logged into
// Facebook, but we don't know if the access token is valid. An access
// token is invalid if the user logged out of Facebook.

if ($user) {
  try {
    // Proceed knowing you have a logged in user who's authenticated.
    // Retrieving user's friend list using fb graph api
    $user_profile = $facebook->api('/me','GET');

  } catch (FacebookApiException $e) {
    error_log($e);
    $user = null;
  }
}

// Login or logout url will be needed depending on current user state.
if (!$user) {
  $loginUrl = $facebook->getLoginUrl(array(
    'scope' => 'user_likes'
  ));
}

0 个答案:

没有答案