This is the graph api code by which i am getting fullname, email and facebook id.. what i need is to get only first name of a user by graph api but i have no clue to how to do that? any help with it.
$request = new FacebookRequest($sess, 'GET', '/me');
// from response get graph object
$response = $request->execute();
$graph = $response->getGraphObject(GraphUser::className());
// use graph object methods to get user details
$graphObject = $response->getGraphObject();
$fuid = $graphObject->getProperty('id'); // To Get Facebook ID
$ffname = $graphObject->getProperty('name'); // To Get Facebook full name
$femail = $graphObject->getProperty('email'); //email
Like this?
$firstName = $graphObject->getProperty('first_name');
If you still don´t get it, try with another API call:
/me?fields=first_name
You can modify your code including all the fields you need including first_name for example the following code including id, full name, first name, last name and email
$request = new FacebookRequest( $session, 'GET', '/me?fields=id,name,first_name,last_name,email' );
$response = $request->execute();
// get response
$graphObject = $response->getGraphObject();
$fbfirstname = $graphObject->getProperty('first_name'); // get Facebook first name