From df7b0b15032555bb56a0b4a6d34b41b871da8138 Mon Sep 17 00:00:00 2001 From: matinwd <100ztaa@gmail.com> Date: Mon, 2 Feb 2026 17:40:21 +0330 Subject: [PATCH 1/2] Add wrappers for missing API endpoints --- src/Structure/Fb/Page.php | 23 ++++++++ src/Structure/Fb/Subscriber.php | 99 +++++++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+) diff --git a/src/Structure/Fb/Page.php b/src/Structure/Fb/Page.php index e2dfa74..3566bae 100644 --- a/src/Structure/Fb/Page.php +++ b/src/Structure/Fb/Page.php @@ -316,4 +316,27 @@ public function setBotFieldByName(string $field_name, $field_value): array return $this->getApi()->callMethod($methodName, $arguments, Request::POST); } + /** + * Sets multiple bot fields + * + * Use field_id or field_name to specify the field. + * + * @param array $fields Array of fields with field_id or field_name and field_value + * + * @return array The resulting array that was received from ManyChat API + * @throws CallMethodNotSucceedException If the result of calling method didn't succeed + * @see https://api.manychat.com/swagger#/Page/post_fb_page_setBotFields Documentation + * of /fb/page/setBotFields method at manychat.com. + * + */ + public function setBotFields(array $fields): array + { + $arguments = [ + 'fields' => $fields, + ]; + $methodName = $this->getMethodAddress(__FUNCTION__); + + return $this->getApi()->callMethod($methodName, $arguments, Request::POST); + } + } diff --git a/src/Structure/Fb/Subscriber.php b/src/Structure/Fb/Subscriber.php index d747ee4..fd2886a 100644 --- a/src/Structure/Fb/Subscriber.php +++ b/src/Structure/Fb/Subscriber.php @@ -109,6 +109,34 @@ public function findByCustomField(int $field_id, $field_value): array return $this->getApi()->callMethod($methodName, $arguments, Request::GET); } + /** + * Finds subscriber by system field (email or phone) + * + * Set one parameter: email OR phone + * + * @param string|null $email Subscriber email + * @param string|null $phone Subscriber phone number + * + * @return array The resulting array that was received from ManyChat API + * @throws CallMethodNotSucceedException If the result of calling method didn't succeed + * @see https://api.manychat.com/swagger#/Subscriber/get_fb_subscriber_findBySystemField Documentation + * of /fb/subscriber/findBySystemField method at manychat.com. + * + */ + public function findBySystemField(?string $email = null, ?string $phone = null): array + { + $arguments = []; + if (null !== $email) { + $arguments['email'] = $email; + } + if (null !== $phone) { + $arguments['phone'] = $phone; + } + $methodName = $this->getMethodAddress(__FUNCTION__); + + return $this->getApi()->callMethod($methodName, $arguments, Request::GET); + } + /** * Adds tag by its ID to the subscriber * @@ -251,6 +279,31 @@ public function setCustomFieldByName(int $subscriber_id, string $field_name, $fi return $this->getApi()->callMethod($methodName, $arguments, Request::POST); } + /** + * Sets multiple custom fields for a single subscriber + * + * Use field_id or field_name to specify the field. + * + * @param integer $subscriber_id Subscriber ID + * @param array $fields Array of fields with field_id or field_name and field_value + * + * @return array The resulting array that was received from ManyChat API + * @throws CallMethodNotSucceedException If the result of calling method didn't succeed + * @see https://api.manychat.com/swagger#/Subscriber/post_fb_subscriber_setCustomFields Documentation + * of /fb/subscriber/setCustomFields method at manychat.com. + * + */ + public function setCustomFields(int $subscriber_id, array $fields): array + { + $arguments = [ + 'subscriber_id' => $subscriber_id, + 'fields' => $fields, + ]; + $methodName = $this->getMethodAddress(__FUNCTION__); + + return $this->getApi()->callMethod($methodName, $arguments, Request::POST); + } + /** * Verifies subscriber by signed request * @@ -274,6 +327,52 @@ public function verifyBySignedRequest(int $subscriber_id, string $signed_request return $this->getApi()->callMethod($methodName, $arguments, Request::POST); } + /** + * Updates subscriber data + * + * @param integer $subscriber_id Subscriber ID + * @param string|null $first_name First name + * @param string|null $last_name Last name + * @param string|null $phone Phone number + * @param string|null $email Email + * @param string|null $gender Gender + * @param bool|null $has_opt_in_sms Has opt-in SMS + * @param bool|null $has_opt_in_email Has opt-in Email + * @param string|null $consent_phrase Consent phrase + * + * @return array The resulting array that was received from ManyChat API + * @throws CallMethodNotSucceedException If the result of calling method didn't succeed + * @see https://api.manychat.com/swagger#/Subscriber/post_fb_subscriber_updateSubscriber Documentation + * of /fb/subscriber/updateSubscriber method at manychat.com. + * + */ + public function updateSubscriber( + int $subscriber_id, + ?string $first_name = null, + ?string $last_name = null, + ?string $phone = null, + ?string $email = null, + ?string $gender = null, + ?bool $has_opt_in_sms = null, + ?bool $has_opt_in_email = null, + ?string $consent_phrase = null + ): array { + $arguments = [ + 'subscriber_id' => $subscriber_id, + 'first_name' => $first_name, + 'last_name' => $last_name, + 'phone' => $phone, + 'email' => $email, + 'gender' => $gender, + 'has_opt_in_sms' => $has_opt_in_sms, + 'has_opt_in_email' => $has_opt_in_email, + 'consent_phrase' => $consent_phrase, + ]; + $methodName = $this->getMethodAddress(__FUNCTION__); + + return $this->getApi()->callMethod($methodName, $arguments, Request::POST); + } + /** * Create new subscriber * From 35c30a3a3710bd82cb7c508902209cb49d3fb1b4 Mon Sep 17 00:00:00 2001 From: matinwd <100ztaa@gmail.com> Date: Mon, 2 Feb 2026 17:58:13 +0330 Subject: [PATCH 2/2] Update docs for new endpoint wrappers --- docs/class-ManyChat.Structure.Fb.Page.html | 38 +++++- ...lass-ManyChat.Structure.Fb.Subscriber.html | 112 +++++++++++++++++- ...urce-class-ManyChat.Structure.Fb.Page.html | 28 ++++- ...lass-ManyChat.Structure.Fb.Subscriber.html | 104 +++++++++++++++- 4 files changed, 274 insertions(+), 8 deletions(-) diff --git a/docs/class-ManyChat.Structure.Fb.Page.html b/docs/class-ManyChat.Structure.Fb.Page.html index 6b5394f..046c81f 100644 --- a/docs/class-ManyChat.Structure.Fb.Page.html +++ b/docs/class-ManyChat.Structure.Fb.Page.html @@ -673,6 +673,43 @@
+ public
+
+
+
+