Skip to content

Commit d85f677

Browse files
committed
Add Recipient type support.
1 parent d3f7d6f commit d85f677

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Changelog
22

3-
All notable changes to `facebook` will be documented in this file
3+
All notable changes to this project will be documented in this file
44

55
## 1.0.0 - 201X-XX-XX
66

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public function routeNotificationForFacebook()
140140

141141
### Available Message methods
142142

143-
- `to($userIdOrPhoneNumber)`: (string) Recipient's page-scoped User ID or Phone number of with the format `+1(212)555-2368`. **NOTE:** Sending a message to phone numbers requires the `pages_messaging_phone_number` permission. Refer [docs](https://developers.facebook.com/docs/messenger-platform/send-api-reference#phone_number) for more information.
143+
- `to($pageScopedIdOrPhoneNumber, $type)`: (string) Recipient's page-scoped User `id`, `phone_number`, `user_ref`, `post_id` or `comment_id` (as one of the supported types). Phone number supported format `+1(212)555-2368`. **NOTE:** Sending a message to phone numbers requires the `pages_messaging_phone_number` permission. Refer [docs](https://developers.facebook.com/docs/messenger-platform/send-api-reference#phone_number) for more information.
144144
- `text('')`: (string) Notification message.
145145
- `attach($attachment_type, $url)`: (AttachmentType, string) An attachment type (IMAGE, AUDIO, VIDEO, FILE) and the url of this attachment
146146
- `buttons($buttons = [])`: (array) An array of "Call to Action" buttons (Created using `NotificationChannels\Facebook\Components\Button::create()`). You can add up to 3 buttons of one of the following types: `web_url`, `postback` or `phone_number`. See Button methods below for more details.

src/FacebookMessage.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,13 @@ public function __construct(string $text = '')
7070
* @param string $recipient ID of recipient or Phone number of the recipient
7171
* with the format +1(212)555-2368
7272
*
73+
* @param string $type Recipient Type: id, user_ref, phone_number, post_id, comment_id.
74+
*
7375
* @return $this
7476
*/
75-
public function to(string $recipient): self
77+
public function to(string $recipient, string $type = 'id'): self
7678
{
77-
$this->recipient = $recipient;
79+
$this->recipient = [$type => $recipient];
7880

7981
return $this;
8082
}

0 commit comments

Comments
 (0)