Search code examples
javascriptfacebookfacebook-sharer

How to get id or name of a facebook user when it share my link


i'm developing a page in with there are many facebook share button.

My page has url like: http://mydomain.com/follow/show_info?id=xxxx

what i like to do is to get info about the user that is sharing my page instead to have

http://mydomain.com/follow/show_info?id=xxxx&name=Name%20Surname

so i can put that name in my page like for example:

The user Name Surname has shared this page.. share that page you too!

Is possible? Thanks!!!


Solution

  • FB.api('/me', function(response) {
        alert("Name: "+ response.name + "\nFirst name: "+ response.first_name + "ID: "+response.id);
        var img_link = "http://graph.facebook.com/"+response.id+"/picture"
    });
    

    by this you can extract current logedin user uid and name and image what you have to do when someone triger for share catch these by java script

    here are some more link which will help you more

    http://developers.facebook.com/docs/reference/api/user/

    http://developers.facebook.com/docs/reference/javascript/

    and

    http://developers.facebook.com/docs/reference/javascript/FB.api/