2012-02-21 4 views

答えて

8

認証後に必要な場所にアプリをリダイレクトするには、このURLを変更する必要があります。

You have to change this URL to redirect you app where you want after authentication.

か、すべてのこの

最初に行うことができます、あなたはPHP SDKを編集する必要はありません、以下のユーザを認証してからランディングページにリダイレクトするためのサンプルです、

あなたが交換することを確認してください:

自分のFacebookのアプリケーションIDを使用して-APP-ID-HERE

その後、リンク先ページのURL

<?php 

    // Requires Facebook PHP SDK 3.0.1: https://github.com/facebook/php-sdk/ 
    require ('facebook.php'); 

    define('FACEBOOK_APP_ID',"YOUR-APP-ID-HERE"); 
    define('FACEBOOK_SECRET',"YOUR-APP-API-SECRET-HERE"); 
    define('REDIRECT_URI',"YOUR-REDIRECT-URL-HERE"); 
    $user = null; 

    $facebook = new Facebook(array(
     'appId' => FACEBOOK_APP_ID, 
     'secret' => FACEBOOK_SECRET, 
     'cookie' => true 
    )); 

    $user = $facebook->getUser(); // Get the UID of the connected user, or 0 if the Facebook user is not connected. 

    if($user == 0) { 
     // If the user is not connected to your application, redirect the user to authentication page 
     /** 
     * Get a Login URL for use with redirects. By default, full page redirect is 
     * assumed. If you are using the generated URL with a window.open() call in 
     * JavaScript, you can pass in display=popup as part of the $params. 
     * 
     * The parameters: 
     * - redirect_uri: the url to go to after a successful login 
     * - scope: comma separated list of requested extended perms 
     */ 

     $login_url = $facebook->getLoginUrl($params = array('redirect_uri' => REDIRECT_URI)); 

     echo ("<script> top.location.href='".$login_url."'</script>"); 

    } else { 
     // if the user is already connected, then redirect them to landing page or show some content 
     echo ("<script> window.location.href='".REDIRECT_URI."'</script>"); 
    } 

?> 

と自分のFacebookのアプリケーション秘密鍵

YOUR-REDIRECT-URL-HEREと

YOUR-APP-API-SECRET-ここでは、拡張アクセス権を取得したい場合は、単に例:

$login_url = $facebook->getLoginUrl($params = array('redirect_uri' => REDIRECT_URI,'scope' => 'comma-separated-list-of-requested-extended-perms')); 
+0

それはうまく働いてくれてありがとう:) – user964104

1

アプリの設定ページでリダイレクトURLを変更します。

+0

「http://apps.facebook.com/APPID/」に変更して、別の「スコープ」パラメータをログインURLに追加しますか?それはどういう意味ですか? – user964104

+0

リンクがアプリページに設定されている場合、マイクは「次の」値をあなたが指したい場所に変更すると言っています。 –

+0

lol?私はそれをやっている – user964104

関連する問題