Skip to content

Commit

Permalink
Upgraded Graph API to v3.0 as v2.6 would be deprecated on July 13, 20…
Browse files Browse the repository at this point in the history
…18 (#67)
  • Loading branch information
simmatrix authored and mpociot committed Jul 20, 2018
1 parent 705e8e0 commit d26cb64
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/Commands/AddGreetingText.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function handle()
}

$response = $this->http->post(
'https://graph.facebook.com/v2.6/me/messenger_profile?access_token='.config('botman.facebook.token'),
'https://graph.facebook.com/v3.0/me/messenger_profile?access_token='.config('botman.facebook.token'),
[], $payload);

$responseObject = json_decode($response->getContent());
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/AddPersistentMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function handle()
exit;
}

$response = $this->http->post('https://graph.facebook.com/v2.6/me/messenger_profile?access_token='.config('botman.facebook.token'),
$response = $this->http->post('https://graph.facebook.com/v3.0/me/messenger_profile?access_token='.config('botman.facebook.token'),
[], $payload);

$responseObject = json_decode($response->getContent());
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/AddStartButtonPayload.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function handle()
}

$response = $this->http->post(
'https://graph.facebook.com/v2.6/me/messenger_profile?access_token='.config('botman.facebook.token'),
'https://graph.facebook.com/v3.0/me/messenger_profile?access_token='.config('botman.facebook.token'),
[],
[
'get_started' => [
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/WhitelistDomains.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function handle()
exit;
}

$response = $this->http->post('https://graph.facebook.com/v2.6/me/messenger_profile?access_token='.config('botman.facebook.token'),
$response = $this->http->post('https://graph.facebook.com/v3.0/me/messenger_profile?access_token='.config('botman.facebook.token'),
[], ['whitelisted_domains' => $payload]);

$responseObject = json_decode($response->getContent());
Expand Down
2 changes: 1 addition & 1 deletion src/FacebookDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class FacebookDriver extends HttpDriver implements VerifiesService
/** @var DriverEventInterface */
protected $driverEvent;

protected $facebookProfileEndpoint = 'https://graph.facebook.com/v2.6/';
protected $facebookProfileEndpoint = 'https://graph.facebook.com/v3.0/';

/** @var bool If the incoming request is a FB postback */
protected $isPostback = false;
Expand Down
26 changes: 13 additions & 13 deletions tests/FacebookDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public function it_returns_the_user_object()
$facebookResponse = '{"first_name":"John","last_name":"Doe","profile_pic":"https://facebook.com/profilepic","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/v2.6/1433960459967306?fields=first_name,last_name,profile_pic,locale,timezone,gender,is_payment_enabled,last_ad_referral&access_token=Foo')->andReturn(new Response($facebookResponse));
$htmlInterface->shouldReceive('get')->once()->with('https://graph.facebook.com/v3.0/1433960459967306?fields=first_name,last_name,profile_pic,locale,timezone,gender,is_payment_enabled,last_ad_referral&access_token=Foo')->andReturn(new Response($facebookResponse));

$driver = $this->getDriver($request, null, '', $htmlInterface);
$message = $driver->getMessages()[0];
Expand All @@ -227,7 +227,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/v2.6/1433960459967306?fields=first_name,last_name,profile_pic,locale,timezone,gender,is_payment_enabled,last_ad_referral&access_token=Foo')->andReturn(new Response('{}'));
$htmlInterface->shouldReceive('get')->once()->with('https://graph.facebook.com/v3.0/1433960459967306?fields=first_name,last_name,profile_pic,locale,timezone,gender,is_payment_enabled,last_ad_referral&access_token=Foo')->andReturn(new Response('{}'));

$driver = $this->getDriver($request, null, '', $htmlInterface);
$driver->getMessages()[0];
Expand Down Expand Up @@ -298,7 +298,7 @@ public function it_can_reply_string_messages()
];

$htmlInterface = m::mock(Curl::class);
$htmlInterface->shouldReceive('post')->once()->with('https://graph.facebook.com/v2.6/me/messages', [], [
$htmlInterface->shouldReceive('post')->once()->with('https://graph.facebook.com/v3.0/me/messages', [], [
'messaging_type' => 'RESPONSE',
'recipient' => [
'id' => '1234567890',
Expand Down Expand Up @@ -347,7 +347,7 @@ public function it_can_reply_with_additional_parameters()
];

$htmlInterface = m::mock(Curl::class);
$htmlInterface->shouldReceive('post')->once()->with('https://graph.facebook.com/v2.6/me/messages', [], [
$htmlInterface->shouldReceive('post')->once()->with('https://graph.facebook.com/v3.0/me/messages', [], [
'messaging_type' => 'RESPONSE',
'recipient' => [
'id' => '1234567890',
Expand Down Expand Up @@ -380,7 +380,7 @@ public function it_throws_exception_while_sending_message()
$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('post')->once()->with('https://graph.facebook.com/v2.6/me/messages', [], [
$htmlInterface->shouldReceive('post')->once()->with('https://graph.facebook.com/v3.0/me/messages', [], [
'messaging_type' => 'RESPONSE',
'recipient' => [
'id' => '1234567890',
Expand Down Expand Up @@ -475,7 +475,7 @@ public function it_can_reply_questions()
$question = Question::create('How are you doing?')->addButton(Button::create('Great')->value('great'))->addButton(Button::create('Good')->value('good'));

$htmlInterface = m::mock(Curl::class);
$htmlInterface->shouldReceive('post')->once()->with('https://graph.facebook.com/v2.6/me/messages', [], [
$htmlInterface->shouldReceive('post')->once()->with('https://graph.facebook.com/v3.0/me/messages', [], [
'messaging_type' => 'RESPONSE',
'recipient' => [
'id' => '1234567890',
Expand Down Expand Up @@ -519,7 +519,7 @@ public function it_can_reply_questions_with_additional_button_parameters()
$question = Question::create('How are you doing?')->addButton(Button::create('Great')->value('great')->additionalParameters(['foo' => 'bar']))->addButton(Button::create('Good')->value('good'));

$htmlInterface = m::mock(Curl::class);
$htmlInterface->shouldReceive('post')->once()->with('https://graph.facebook.com/v2.6/me/messages', [], [
$htmlInterface->shouldReceive('post')->once()->with('https://graph.facebook.com/v3.0/me/messages', [], [
'messaging_type' => 'RESPONSE',
'recipient' => [
'id' => '1234567890',
Expand Down Expand Up @@ -567,7 +567,7 @@ public function it_can_reply_quick_replies_with_special_types()
->addAction(QuickReplyButton::create()->type('user_phone_number'));

$htmlInterface = m::mock(Curl::class);
$htmlInterface->shouldReceive('post')->once()->with('https://graph.facebook.com/v2.6/me/messages', [], [
$htmlInterface->shouldReceive('post')->once()->with('https://graph.facebook.com/v3.0/me/messages', [], [
'messaging_type' => 'RESPONSE',
'recipient' => [
'id' => '1234567890',
Expand Down Expand Up @@ -659,7 +659,7 @@ public function it_can_reply_message_objects()
];

$htmlInterface = m::mock(Curl::class);
$htmlInterface->shouldReceive('post')->once()->with('https://graph.facebook.com/v2.6/me/messages', [], [
$htmlInterface->shouldReceive('post')->once()->with('https://graph.facebook.com/v3.0/me/messages', [], [
'messaging_type' => 'RESPONSE',
'recipient' => [
'id' => '1234567890',
Expand Down Expand Up @@ -709,7 +709,7 @@ public function it_can_reply_message_objects_with_image()
];

$htmlInterface = m::mock(Curl::class);
$htmlInterface->shouldReceive('post')->once()->with('https://graph.facebook.com/v2.6/me/messages', [], [
$htmlInterface->shouldReceive('post')->once()->with('https://graph.facebook.com/v3.0/me/messages', [], [
'messaging_type' => 'RESPONSE',
'recipient' => [
'id' => '1234567890',
Expand Down Expand Up @@ -764,7 +764,7 @@ public function it_can_reply_message_objects_with_audio()
];

$htmlInterface = m::mock(Curl::class);
$htmlInterface->shouldReceive('post')->once()->with('https://graph.facebook.com/v2.6/me/messages', [], [
$htmlInterface->shouldReceive('post')->once()->with('https://graph.facebook.com/v3.0/me/messages', [], [
'messaging_type' => 'RESPONSE',
'recipient' => [
'id' => '1234567890',
Expand Down Expand Up @@ -819,7 +819,7 @@ public function it_can_reply_message_objects_with_file()
];

$htmlInterface = m::mock(Curl::class);
$htmlInterface->shouldReceive('post')->once()->with('https://graph.facebook.com/v2.6/me/messages', [], [
$htmlInterface->shouldReceive('post')->once()->with('https://graph.facebook.com/v3.0/me/messages', [], [
'messaging_type' => 'RESPONSE',
'recipient' => [
'id' => '1234567890',
Expand Down Expand Up @@ -941,7 +941,7 @@ public function it_calls_generic_event_for_unkown_facebook_events()
public function it_can_reply_mark_seen_sender_action()
{
$htmlInterface = m::mock(Curl::class);
$htmlInterface->shouldReceive('post')->once()->with('https://graph.facebook.com/v2.6/me/messages', [], [
$htmlInterface->shouldReceive('post')->once()->with('https://graph.facebook.com/v3.0/me/messages', [], [
'recipient' => [
'id' => '1234567890',
],
Expand Down

0 comments on commit d26cb64

Please sign in to comment.