Facebook App授权

时间:2012-03-27 14:47:09

标签: php javascript facebook

我创建了一个应用,可以找到此应用here

当有人第一次使用该应用程序时,一切都正常工作。它会生成一个对话框,允许用户使用它来查看我请求的类型或权限 -

$url = $facebook->getLoginUrl(array(
'canvas' => 1,
'req_perms' => 'publish_stream, email, offline_access',
'fbconnect' => 0
));

用户点击“确定”后,会将其重定向到我的应用所在的网址,而不是重定向到Facebook内应用的网址。

我使用此代码的其他代码 -

include_once("includes/src/facebook.php");
include_once("includes/src/facebook_config.php");
$facebook = new Facebook(array(
'appId'  => FACEBOOK_APP_ID,
'secret' => FACEBOOK_SECRET_KEY,
'cookie' => false,
'domain' => 'syncro-it.co.uk'
));


<div id="fb-root"></div>
        <script>
        window.fbAsyncInit = function() {
        FB.init({
            appId  : '<?=FACEBOOK_APP_ID?>',
            status : true, // check login status
            cookie : true, // enable cookies to allow the server to access the session
            xfbml  : true  // parse XFBML
        });
        FB.Canvas.setSize();
        };

        (function() {
        var e = document.createElement('script');
        e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
        e.async = true;
        document.getElementById('fb-root').appendChild(e);
        }());
        </script>

有没有人遇到过这个?如果是这样,我会错过一些愚蠢的行为吗?

2 个答案:

答案 0 :(得分:1)

试试这个:

<?
  // Remember to copy files from the SDK's src/ directory to a
  // directory in your application on the server, such as php-sdk/
  require_once('facebook.php');

  $config = array(
    'appId' => '2XXXXXXXXXXXX36',
    'secret' => 'XXXXXXXXXXXXXXXX43d18d86f157d',
    'fileUpload' => true,
  );

  $facebook = new Facebook($config);
  $user_id = $facebook->getUser();
if($user_id) {
    try {
        $user_profile = $facebook->api('/me','GET');
                echo $user_profile['birthday'];
                     //----------------------------------
                     //PUSH UR CODE HERE
                     //----------------------------------
    } 
catch(FacebookApiException $e) 
{
        $login_url = $facebook->getLoginUrl( array(
       'scope' => 'user_birthday'
        )); 
echo "<script type='text/javascript'>top.location.href = '$login_url';</script>";
exit;
}
}
else
{
        $login_url = $facebook->getLoginUrl( array(
                       'scope' => 'user_birthday'
                     )); 
    echo "<script type='text/javascript'>top.location.href = '$login_url';                     </script>";
                exit;
        }
    ?>

答案 1 :(得分:0)

这只是使用应用程序的设置更改回旧的权限对话框