Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/FacebookDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ public function getUser(IncomingMessage $matchingMessage)
$messagingDetails = $this->event->get('messaging')[0];

// field string available at Facebook
$fields = 'name,first_name,last_name,profile_pic';
$fields = 'name,first_name,last_name';

// WORKPLACE (Facebook for companies)
// if community isset in sender Object, it is a request done by workplace
Expand Down
7 changes: 3 additions & 4 deletions tests/FacebookDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,10 @@ public function it_returns_the_user_object()
{
$request = '{"object":"page","entry":[{"id":"111899832631525","time":1480279487271,"messaging":[{"sender":{"id":"1433960459967306"},"recipient":{"id":"111899832631525"},"timestamp":1480279487147,"message":{"mid":"mid.1480279487147:4388d3b344","seq":36,"text":"Hi Julia"}}]}]}';

$facebookResponse = '{"first_name":"John","last_name":"Doe","profile_pic":"https://facebook.com/profilepic","locale":"en_US","timezone":2,"gender":"male","is_payment_enabled":true}';
$facebookResponse = '{"first_name":"John","last_name":"Doe","locale":"en_US","timezone":2,"gender":"male","is_payment_enabled":true}';

$htmlInterface = m::mock(Curl::class);
$htmlInterface->shouldReceive('get')->once()->with('https://graph.facebook.com/v3.0/1433960459967306?fields=name,first_name,last_name,profile_pic&access_token=Foo')->andReturn(new Response($facebookResponse));
$htmlInterface->shouldReceive('get')->once()->with('https://graph.facebook.com/v3.0/1433960459967306?fields=name,first_name,last_name&access_token=Foo')->andReturn(new Response($facebookResponse));

$driver = $this->getDriver($request, null, '', $htmlInterface);
$message = $driver->getMessages()[0];
Expand All @@ -213,7 +213,6 @@ public function it_returns_the_user_object()
$this->assertEquals('John', $user->getFirstName());
$this->assertEquals('Doe', $user->getLastName());
$this->assertNull($user->getUsername());
$this->assertEquals('https://facebook.com/profilepic', $user->getProfilePic());
$this->assertEquals('en_US', $user->getLocale());
$this->assertEquals('2', $user->getTimezone());
$this->assertEquals('male', $user->getGender());
Expand Down Expand Up @@ -243,7 +242,7 @@ public function it_throws_exception_in_get_user()
$request = '{"object":"page","entry":[{"id":"111899832631525","time":1480279487271,"messaging":[{"sender":{"id":"1433960459967306"},"recipient":{"id":"111899832631525"},"timestamp":1480279487147,"message":{"mid":"mid.1480279487147:4388d3b344","seq":36,"text":"Hi Julia"}}]}]}';

$htmlInterface = m::mock(Curl::class);
$htmlInterface->shouldReceive('get')->once()->with('https://graph.facebook.com/v3.0/1433960459967306?fields=name,first_name,last_name,profile_pic&access_token=Foo')->andReturn(new Response('{}'));
$htmlInterface->shouldReceive('get')->once()->with('https://graph.facebook.com/v3.0/1433960459967306?fields=name,first_name,last_name&access_token=Foo')->andReturn(new Response('{}'));

$driver = $this->getDriver($request, null, '', $htmlInterface);
$driver->getMessages()[0];
Expand Down