开发者

how to get the email address and the user Id in fbml using cake php

开发者 https://www.devze.com 2023-01-26 02:35 出处:网络
I have used one javascript function which is being called after login on facebook connect. var FB_API_KEY = \"api key\";

I have used one javascript function which is being called after login on facebook connect.

    var FB_API_KEY = "api key";
var FB_CHANNEL_PATH = "xd_receiver.htm";

FB.init(FB_API_KEY, FB_CHANNEL_PATH, {permsToRequestOnConnect : "email"});
FB.Connect.ifUserConnected(FB_ConnectPostAuthorization);

function FB_ConnectPostAuthorization() {

    var user_box = document.getElementById("user_id");
    user_box.innerHTML = 
    "<span>"
    +"<fb:profile-pic uid='loggedinuser' facebook-logo='true'></fb:profile-pic>"        
    +"Welcome , <fb:name uid ='loggedinuser' useyou='false'></fb:name>" 
    +"You are signed in with your facebook account"
    +"</span>";

    FB.XFBML.Host.parseDomTree();


    FB_RequireFeatures(["Api"], function(){
        var api = FB.Facebook.apiClient;
        var fb_uid = api.get_session().uid;

        $.post('/users/fb_login/', {'fb_uid': fb_uid}, function(response) {
            if (response != "yes") {
                api开发者_如何学JAVA.users_hasAppPermission("email", function(result) {
                    if (!result) {
                        FB.Connect.showPermissionDialog("email", redirect_to_done_page);
                    } else {
                        redirect_to_done_page()
                    }
                })
            } else {
                redirect_to_done_page()
            }
        });
    });       
}

function redirect_to_done_page() {
    window.location = "xyz";
}

I have added a facebook connect button which calls the above function.

I am only able to get the user name and profile pic in through fbml tags. How do I get the user email and user id.

Please guide me.


I don't think you can get email through fbml, because with it you can just show it and there is no point.

Actually you need to have a PHP part of the FB API which you can help you with that task.

Although you can use this very good plugin for CakePHP. It's really easy to get it working and you can get the user's email for sure.


I've never used the FB api,but I'd be surprised if they gave out emails. Oh... it's Facebook. I eat my words.

0

精彩评论

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

关注公众号