src/FacebookDriver.php
public function getUserWithFields(array $fields, IncomingMessage $matchingMessage)
    {
        $messagingDetails = $this->event->get('messaging')[0];
        // implode field array to create concatinated comma string
        $fields = implode(',', $fields);
        // WORKPLACE (Facebook for companies)
        // if community isset in sender Object, it is a request done by workplace
        if (isset($messagingDetails['sender']['community'])) {
            $fields = 'first_name,last_name,email,title,department,employee_number,primary_phone,primary_address,picture,link,locale,name,name_format,updated_time';
        }
        $userInfoData = $this->http->get($this->facebookProfileEndpoint.$matchingMessage->getSender().'?fields='.$fields.'&access_token='.$this->config->get('token'));
        $this->throwExceptionIfResponseNotOk($userInfoData);
        $userInfo = json_decode($userInfoData->getContent(), true);
        $firstName = $userInfo['first_name'] ?? null;
        $lastName = $userInfo['last_name'] ?? null;

        return new User($matchingMessage->getSender(), $firstName, $lastName, null, $userInfo);
    }
public function getUserWithFields(array $fields, IncomingMessage $matchingMessage)
    {
        $messagingDetails = $this->event->get('messaging')[0];
        // implode field array to create concatinated comma string
        $fields = implode(',', $fields);
        // WORKPLACE (Facebook for companies)
        // if community isset in sender Object, it is a request done by workplace
        if (isset($messagingDetails['sender']['community'])) {
            $fields = 'first_name,last_name,email,title,department,employee_number,primary_phone,primary_address,picture,link,locale,name,name_format,updated_time';
        }
        $userInfoData = $this->http->get($this->facebookProfileEndpoint.$matchingMessage->getSender().'?fields='.$fields.'&access_token='.$this->config->get('token'));
        $this->throwExceptionIfResponseNotOk($userInfoData);
        $userInfo = json_decode($userInfoData->getContent(), true);
        $firstName = $userInfo['first_name'] ?? null;
        $lastName = $userInfo['last_name'] ?? null;

        return new User($matchingMessage->getSender(), $firstName, $lastName, null, $userInfo);
    }
public function getUserWithFields ( array $ fields , IncomingMessage $ matchingMessage ) { $ messagingDetails = $ this -> event -> get ( 'messaging' ) [ 0 ] ; // implode field array to create concatinated comma string $ fields = implode ( ',' , $ fields ) ; // WORKPLACE (Facebook for companies) // if community isset in sender Object, it is a request done by workplace if ( isset ( $ messagingDetails [ 'sender' ] [ 'community' ] ) ) { $ fields = 'first_name,last_name,email,title,department,employee_number,primary_phone,primary_address,picture,link,locale,name,name_format,updated_time' ; } $ userInfoData = $ this -> http -> get ( $ this -> facebookProfileEndpoint . $ matchingMessage -> getSender ( ) . '?fields=' . $ fields . '&access_token=' . $ this -> config -> get ( 'token' ) ) ; $ this -> throwExceptionIfResponseNotOk ( $ userInfoData ) ; $ userInfo = json_decode ( $ userInfoData -> getContent ( ) , true ) ; $ firstName = $ userInfo [ 'first_name' ] ?? null ; $ lastName = $ userInfo [ 'last_name' ] ?? null ; return new User ( $ matchingMessage -> getSender ( ) , $ firstName , $ lastName , null , $ userInfo ) ; }
Retrieve specific User field information.

@param array $fields
@param IncomingMessage $matchingMessage
@return User
@throws FacebookException
Retrieve specific User field information .