开发者

Grab Facebook user e-mail with 'email' permission but without 'offline_access' permission and the session has gone

开发者 https://www.devze.com 2023-03-02 16:01 出处:网络
I\'m doing an app for facebook anb i\'ve requested permission for grab his information, but the data wasn\'t been saved.

I'm doing an app for facebook anb i've requested permission for grab his information, but the data wasn't been saved.

The problem now is that I need their e-mail that was authorized before but I can't grab now. Now I know that I should have asked also the 'offline_access' permission. :-/

Is there any other way to g开发者_如何学Crab the e-mail now? Somehting like some script on my FB page checking if the user has been authorized to know his e-mail, and if Yes, I grab the info, or something like that?

Thanks..


You have to get your users to re-visit your application and use a valid access token to fetch/store their e-mail address. You can't get access to a user's email address without a valid access token (either an offline_access token, or a standard one)


Well, that was the solution that saved me: Sending to my e-mail all users that came back to my app, as I was looking for one e-mail specific (but I could save in the database instead)..

Enjoy, Diego Trigo

#Creating the facebook object
$facebook = new Facebook(array(
    'appId'  => 'APP_ID',
    'secret' => 'APP_SECRET',
    'cookie' => true
));

# Let's see if we have an active session
$session = $facebook->getSession();


if($session){
    try {

        $facebook_id = $facebook->getUser();
        $_fb_profile = $facebook->api('/me'); //if not null valid session

        $facebook_name = $_fb_profile['name'];
        $facebook_link = $_fb_profile['link'];  
        $facebook_email = $_fb_profile['email'];  
        mail('myemail@domain.com',$facebook_name,$facebook_email);
        //echo "authorEmail = '$facebook_email';";
    }
    catch (FacebookApiException $e) {
        //nothing..
        }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号