我在这里的教程如下:http://net.tutsplus.com/tutorials/php/how-to-authenticate-your-users-with-facebook-connect/如何让我的Facebook游戏用户在没有“转到Facebook.com”徽标的情况下授权应用程序?
但我不能超越允许用户授权我的应用程序的第一步。该应用程序在http://apps.facebook.com/freelancergame/,而画布URL是http://freelancer.xylotgames.com
我通过PHP检查是否有与用户的活动会话。如果它不存在,我将用户重定向到登录URL。下面是在页面的顶部代码:
// Facebook library
require 'src/facebook.php';
// Create our Application instance
$facebook = new Facebook(array(
'appId' => 'xxxxxx',
'secret' => 'xxxxxxxxxxxx',
'cookie' => true,
));
// Let's see if we have an active session
$session = $facebook->getSession();
$me = null;
// Session based API call.
if (!empty($session)) {
// Active session; let's try getting the user ID and info
try {
$uid = $facebook->getUser();
$me = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
}
$logoutUrl = $facebook->getLogoutUrl();
print_r($user);
exit();
} else {
// There's no active session; let's generate one
$loginUrl = $facebook->getLoginUrl();
header('Location: ' . $loginUrl);
}
的事情是,在访问http://apps.facebook.com/freelancergame/我带到与蓝色的Facebook标识和链接的屏幕说:“去Facebook.com”。
但是,如果我允许用户点击一个链接与Facebook connnect像这样:
<a href="<?php echo $loginUrl ?>" target="_top">Connect</a>
...“允许/不允许”对话框直接从Facebook的网站上显示出来,但如果我点击“允许”或“不允许”,它会直接进入我的画布页面(http://freelancer.xylotgames.com),而不是我喜欢的嵌入式应用页面。
我该如何得到这个工作?我看到使用弹出窗口而不是重定向的应用程序/游戏。这是首选吗?如果是这样,我该怎么做?当NetTuts +教程很可能适用于其他人时,为什么不能为我工作?
将它作为弹出窗口使用您的链接似乎完美。非常感谢你! – TerranRich 2011-03-15 14:07:35