diff --git a/src/FacebookDriver.php b/src/FacebookDriver.php index b4b8563..7750728 100644 --- a/src/FacebookDriver.php +++ b/src/FacebookDriver.php @@ -34,6 +34,10 @@ class FacebookDriver extends HttpDriver implements VerifiesService { const HANDOVER_INBOX_PAGE_ID = '263902037430900'; + const TYPE_RESPONSE = 'RESPONSE'; + const TYPE_UPDATE = 'UPDATE'; + const TYPE_MESSAGE_TAG = 'MESSAGE_TAG'; + /** @var string */ protected $signature; @@ -347,6 +351,7 @@ public function buildServicePayload($message, $matchingMessage, $additionalParam $recipient = ['id' => $matchingMessage->getSender()]; } $parameters = array_merge_recursive([ + 'messaging_type' => self::TYPE_RESPONSE, 'recipient' => $recipient, 'message' => [ 'text' => $message, @@ -384,6 +389,7 @@ public function buildServicePayload($message, $matchingMessage, $additionalParam /** * @param mixed $payload * @return Response + * @throws FacebookException */ public function sendPayload($payload) { @@ -406,6 +412,7 @@ public function isConfigured() * * @param IncomingMessage $matchingMessage * @return User + * @throws FacebookException */ public function getUser(IncomingMessage $matchingMessage) { diff --git a/tests/FacebookDriverTest.php b/tests/FacebookDriverTest.php index 6310867..820aa72 100644 --- a/tests/FacebookDriverTest.php +++ b/tests/FacebookDriverTest.php @@ -299,6 +299,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', [], [ + 'messaging_type' => 'RESPONSE', 'recipient' => [ 'id' => '1234567890', ], @@ -347,6 +348,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', [], [ + 'messaging_type' => 'RESPONSE', 'recipient' => [ 'id' => '1234567890', ], @@ -379,6 +381,7 @@ public function it_throws_exception_while_sending_message() $htmlInterface = m::mock(Curl::class); $htmlInterface->shouldReceive('post')->once()->with('https://graph.facebook.com/v2.6/me/messages', [], [ + 'messaging_type' => 'RESPONSE', 'recipient' => [ 'id' => '1234567890', ], @@ -473,6 +476,7 @@ public function it_can_reply_questions() $htmlInterface = m::mock(Curl::class); $htmlInterface->shouldReceive('post')->once()->with('https://graph.facebook.com/v2.6/me/messages', [], [ + 'messaging_type' => 'RESPONSE', 'recipient' => [ 'id' => '1234567890', ], @@ -516,6 +520,7 @@ public function it_can_reply_questions_with_additional_button_parameters() $htmlInterface = m::mock(Curl::class); $htmlInterface->shouldReceive('post')->once()->with('https://graph.facebook.com/v2.6/me/messages', [], [ + 'messaging_type' => 'RESPONSE', 'recipient' => [ 'id' => '1234567890', ], @@ -563,6 +568,7 @@ public function it_can_reply_quick_replies_with_special_types() $htmlInterface = m::mock(Curl::class); $htmlInterface->shouldReceive('post')->once()->with('https://graph.facebook.com/v2.6/me/messages', [], [ + 'messaging_type' => 'RESPONSE', 'recipient' => [ 'id' => '1234567890', ], @@ -654,6 +660,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', [], [ + 'messaging_type' => 'RESPONSE', 'recipient' => [ 'id' => '1234567890', ], @@ -703,6 +710,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', [], [ + 'messaging_type' => 'RESPONSE', 'recipient' => [ 'id' => '1234567890', ], @@ -757,6 +765,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', [], [ + 'messaging_type' => 'RESPONSE', 'recipient' => [ 'id' => '1234567890', ], @@ -811,6 +820,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', [], [ + 'messaging_type' => 'RESPONSE', 'recipient' => [ 'id' => '1234567890', ],