我正在新的Facebook API上创建我的第一个测试应用程序,遗憾的是,我之前看到的许多示例都包含不推荐使用的代码。我遵循典型的例子来验证某人,然后在成功验证后将他们重定向回应用程序。
即使我用应用程序画布的URL指定了一个"next"参数,它总是自动重定向到我的服务器上的应用程序(iFrame之外)。即使省略next,这似乎也是默认行为(它不允许我将应用程序URL指定为redirect_uri,表示它不归应用程序所有,不能将其用作有效的URL)。
这是我现在的代码:
<?php
require_once 'config.php';
/* Get valid session */
//$session = $facebook->getSession();
$user = $facebook->getUser();
if($user) {
try {
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user=null;
}
}
if($user) {
$logoutUrl = $facebook->getLogoutUrl();
} else {
$loginUrl = $facebook->getLoginUrl(array('next'=>'http://apps.facebook.com/fgdeveloper','fbconnect'=>0,'scope'=>'read_stream,publish_stream,user_photos'));
echo '<script>top.location.href="'.$loginUrl.'";</script>';
break;
}
?>
https://www.facebook.com/dialog/permissions.request?app_id=135904836523042&display=page&next=http%3A%2F%2Fww.grooveyorkity.com%2FTestFBApp%2F&response_type=代码&state=05be7caaa1842c9d69d7b0a44f4da6e&fbconnect=1&perms=read_stream%2publish_stream%2用户照片
您可以看到next=
指向您的web服务器,而不是画布url。我还注意到您没有配置SSL。
应用程序设置或您的应用程序中存在错误配置。查看您告诉它使用grooveyorkcity.com的位置,然后将其更改为https://apps.facebook.com/fgdeveloper/postauthlandingpage.htm或者一些这样的。别忘了设置你的https(SSL)url,这样你的应用程序就完全兼容了。