2011-08-29 125 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

相关问题