2011-08-29 122 views
0

我是新來的Facebook應用程序,我使用Facebook的php jdk中的示例代碼進行測試。雖然我有用戶名,名字等,但我沒有收到電子郵件或生日信息。我在這個論壇搜索How to get Users Email Id in Facebook application using PHP?並增加了額外的行'req_perms' =>'email,user_birthday,publish_stream',但結果是一樣的。我送你的代碼:無法從Facebook應用程序獲取電子郵件

public function getLoginUrl($params=array()) { 
    $this->establishCSRFTokenState(); 
    $currentUrl = $this->getCurrentUrl(); 
    return $this->getUrl(
     'www', 
     'dialog/oauth', 
     array_merge(array(
        'client_id' => $this->getAppId(), 
        'req_perms' =>'email,user_birthday,publish_stream', 
        'redirect_uri' => $currentUrl, // possibly overwritten 
        'state' => $this->state), 
        $params)); 
    /** 
    * Get a Logout URL suitable for use with redirects. 
    * 
    * The parameters: 
    * - next: the url to go to after a successful logout 
    * 
    * @param array $params Provide custom parameters 
    * @return string The URL for the logout flow 
    */ 
    public function getLogoutUrl($params=array()) { 
    return $this->getUrl(
     'www', 
     'logout.php', 
     array_merge(array(
     'next' => $this->getCurrentUrl(), 
     'access_token' => $this->getAccessToken(), 
    ), $params) 
    ); 
    } 

而在index.php我檢索電子郵件

echo "E-mail".$user_profile['email']."<br />"; 

回答

0

你已經改變了Facebook SDK庫。你已經編輯了facebook.php的代碼。沒有必要編輯facebook庫的代碼。剛剛從Facebook庫中刪除參數:

'req_perms' =>'email,user_birthday,publish_stream', 

你必須在這裏使用此參數:

$loginUrl = $facebook->getLoginUrl(array('canvas' => 1, 
            'fbconnect' => 0, 
            'scope' => 'email,user_birthday,publish_stream', 
            'next' => CANVAS_PAGE, 
            'cancel_url' => CANVAS_PAGE)); 

改變了req_perms到範圍。現在它將工作正常

+0

感謝您的回覆munjal ....我已經刪除了base_facebook.php和adde在我的index.php中的行。但結果是一樣的!我給你我的應用程序的URL,這可能是有用的apps.facebook.com/nitz_dola_apps – AssamGuy

+0

見上文。我編輯了代碼。 – munjal

+0

許多許多感謝你munjal ..現在完美工作。 – AssamGuy

相關問題