Get the Sender’s Name and Gender in Facebook Graph API

How can I return the senders first name, last name, and gender from the Facebook Graph API when a message is received?

We need two required parameters such the sender id and a page access token. The sender id can be parsed when a message is received while the page access token can be obtained when you link your page to your Facebook app.

Send a get request to the following replacing the variables with the actual values:{ID}?fields={FIELDS_TO_ACCESS_HERE}&access_token={PAGE_ACCESS_TOKEN}

I used Postman to make the GET request and which gives a pretty-printed response of the JSON object.

Return Sender Name and Gender in Facebook Graph API using Postman

Another way is by making a CURL request which gives just the same result.

Return Sender Name and Gender in Facebook Graph API using CURL

You can then use the sender’s details to personalize your response in messenger.

Add comment

E-mail is already registered on the site. Please use the Login form or enter another.

You entered an incorrect username or password

Sorry, you must be logged in to post a comment.

Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.