Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the first_name via graph api?

I can get the picture with this code:

https://graph.facebook.com/userid/picture

but this doesn't work:

https://graph.facebook.com/userid/first_name

How can I get user's name ?

like image 866
xRobot Avatar asked May 19 '12 07:05

xRobot


People also ask

How do I get a phone number from Facebook Graph API?

Phone Number Verification Code To get a phone number's ID, call to https://graph.facebook.com/ v14. 0 /{whatsapp-business-account-ID}/phone_numbers . Replace {whatsapp-business-account-ID} with the ID of the WhatsApp Business Account the phone number belongs to. See Get all phone numbers for an example.

How do I get my Facebook API User ID?

The simplest way to get a copy of the User Profile object is to access the /me endpoint: FB. api('/me', function(response) { }); This will this will return the users name and an ID by default.

How do I open an API graph?

You can access Graph Explorer at: https://developer.microsoft.com/graph/graph-explorer. You can either access demo data without signing in, or you can sign in to a tenant of your own. Use the following steps to build the request: Select the HTTP method.


1 Answers

You cannot get first_name like you are getting picture.

https://graph.facebook.com/userid/?fields=first_name

will get

{
   "first_name": "Jashwant",
   "id": "1137725463"
}

Then you can get first_name by any json parser.

Here's the GIVE_ME_THE_CODE version,

<html>
<head>
<style>

</style>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<script type='text/javascript'>
 $(document).ready(function(){
    $.getJSON('http://graph.facebook.com/jashwantsingh?fields=first_name',function(data){
        $('<p>' + data.first_name + '<p>').appendTo('body');
    })
 })

</script>
</head> 
<body> 

</body>
</html>
like image 100
Jashwant Avatar answered Oct 04 '22 22:10

Jashwant