Twilio Conversation 尝试发送消息时出现致命错误?

Twilio Conversation Fatal error when trying to send message?

我正在尝试按照在线 twilio 示例进行小组对话。我进行了对话并且人们相互联系(我认为)但是当我发送消息时我收到以下错误:

Fatal error: Uncaught Twilio\Exceptions\RestException: [HTTP 412] Unable to create record: Group MMS activation failed in

有人在 PHP 中有工作对话的任何工作样本吗?如果你愿意,我可以 post 我的完整代码(减去键和 phone 数字)

更新:

设置对话的代码:

$conversation = $twilio->conversations->v1->conversations
                                          ->create([
                                                       "friendlyName" => "RawesomePaws"
                                                   ]
                                          );

然后我添加了 Twilio phone 和其他 3 条短信 phone #'s

$participant = $twilio->conversations->v1->conversations("CHb61ad48141884350896047adc23XXXX")
                                         ->participants
                                         ->create([
                                                      "identity" => "Rawesome Orders",
                                                      "messagingBindingProjectedAddress" => "+1408840XXXX"
                                                  ]
                                         );

$participant = $twilio->conversations->v1->conversations("CHb61ad48141884350896047adc237XXXX")
                                         ->participants
                                         ->create([
                                                      "messagingBindingAddress" => "+1408409XXXX"
                                                  ]
                                         );

$participant = $twilio->conversations->v1->conversations("CHb61ad48141884350896047adc237XXXX")
                                         ->participants
                                         ->create([
                                                      "messagingBindingAddress" => "+1815210XXXX"
                                                  ]
                                         );

$participant = $twilio->conversations->v1->conversations("CHb61ad48141884350896047adc237XXXX")
                                         ->participants
                                         ->create([
                                                      "messagingBindingAddress" => "+1408540XXXX"
                                                  ]
                                         );


现在对话已建立,我尝试发送群消息:

$message = $twilio->conversations->v1->conversations("CHb61ad48141884350896047adc237XXXX")
                                     ->messages
                                     ->create([
                                                  "body" => 'Message Body',
                                                  "author" => 'Rawesome Orders',
                                             ]
                                     );

这是我在终端时的输出:

Fatal error: Uncaught Twilio\Exceptions\RestException: [HTTP 412] Unable to create record: Group MMS activation failed in /home/customer/www/sirota-consulting.com/public_html/PPLG/cron/twilio-php-main/src/Twilio/Version.php:88
Stack trace:
#0 /home/customer/www/XXX-consulting.com/public_html/PPLG/cron/twilio-php-main/src/Twilio/Version.php(223): Twilio\Version->exception(Object(Twilio\Http\Response), 'Unable to creat...')
#1 /home/customer/www/XXX-consulting.com/public_html/PPLG/cron/twilio-php-main/src/Twilio/Rest/Conversations/V1/Conversation/MessageList.php(57): Twilio\Version->create('POST', '/Conversations/...', Array, Array, Array)
#2 /home/customer/www/XXX-consulting.com/public_html/PPLG/sms_SendMessage.php(15): Twilio\Rest\Conversations\V1\Conversation\MessageList->create(Object(Twilio\Values))
#3 {main}
  thrown in /home/customer/www/XXX-consulting.com/public_html/PPLG/cron/twilio-php-main/src/Twilio/Version.php on line 88

更新 2 这是来自 phpLog

的完整日志
[24-Apr-2021 01:11:59 UTC] -- BEGIN Twilio API Request --
[24-Apr-2021 01:11:59 UTC] Request Method: POST
[24-Apr-2021 01:11:59 UTC] Request URL: /v1/Conversations/CHb61ad48141884350896047adc237cf45/Messages
[24-Apr-2021 01:11:59 UTC] Request Headers: 
[24-Apr-2021 01:11:59 UTC] User-Agent: twilio-php/6.16.0 (PHP 7.3.27)
[24-Apr-2021 01:11:59 UTC] Accept-Charset: utf-8
[24-Apr-2021 01:11:59 UTC] Content-Type: application/x-www-form-urlencoded
[24-Apr-2021 01:11:59 UTC] Accept: application/json
[24-Apr-2021 01:11:59 UTC] -- END Twilio API Request --
[24-Apr-2021 01:12:00 UTC] Status Code: 412
[24-Apr-2021 01:12:00 UTC] Response Headers:
[24-Apr-2021 01:12:00 UTC] Date:  Sat, 24 Apr 2021 01:12:00 GMT
[24-Apr-2021 01:12:00 UTC] Content-Type:  application/json; charset=utf-8
[24-Apr-2021 01:12:00 UTC] Content-Length:  129
[24-Apr-2021 01:12:00 UTC] Connection:  keep-alive
[24-Apr-2021 01:12:00 UTC] Twilio-Request-Id:  RQbd66fd8e4b548596a430a2646a4376f2
[24-Apr-2021 01:12:00 UTC] Twilio-Request-Duration:  0.195
[24-Apr-2021 01:12:00 UTC] Access-Control-Allow-Origin:  *
[24-Apr-2021 01:12:00 UTC] Access-Control-Allow-Headers:  Accept, Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since
[24-Apr-2021 01:12:00 UTC] Access-Control-Allow-Methods:  GET, POST, DELETE, OPTIONS
[24-Apr-2021 01:12:00 UTC] Access-Control-Expose-Headers:  ETag
[24-Apr-2021 01:12:00 UTC] Access-Control-Allow-Credentials:  true
[24-Apr-2021 01:12:00 UTC] X-Powered-By:  AT-5000
[24-Apr-2021 01:12:00 UTC] X-Shenanigans:  none
[24-Apr-2021 01:12:00 UTC] X-Home-Region:  us1
[24-Apr-2021 01:12:00 UTC] X-API-Domain:  conversations.twilio.com
[24-Apr-2021 01:12:00 UTC] Strict-Transport-Security:  max-age=31536000
[24-Apr-2021 01:12:00 UTC] PHP Fatal error:  Uncaught Twilio\Exceptions\RestException: [HTTP 412] Unable to create record: Group MMS activation failed in /home/customer/www/XXX-consulting.com/public_html/PPLG/cron/twilio-php-main/src/Twilio/Version.php:88
Stack trace:
#0 /home/customer/www/XXX-consulting.com/public_html/PPLG/cron/twilio-php-main/src/Twilio/Version.php(223): Twilio\Version->exception(Object(Twilio\Http\Response), 'Unable to creat...')
#1 /home/customer/www/XXX-consulting.com/public_html/PPLG/cron/twilio-php-main/src/Twilio/Rest/Conversations/V1/Conversation/MessageList.php(57): Twilio\Version->create('POST', '/Conversations/...', Array, Array, Array)
#2 /home/customer/www/XXX-consulting.com/public_html/PPLG/sms_SendMessage.php(15): Twilio\Rest\Conversations\V1\Conversation\MessageList->create(Object(Twilio\Values))
#3 {main}
  thrown in /home/customer/www/XXX-consulting.com/public_html/PPLG/cron/twilio-php-main/src/Twilio/Version.php on line 88

此处为 Twilio 开发人员布道师。

我想这个错误代码还没有公布,我会在内部跟进。不过,我已经找到了一些关于此错误的文档。

Typical reasons for failure include:

  • Less than 3 non-chat participants in the conversation
  • There’s a chat participant in the conversation
  • There’s an existing group conversation with the exact same participants
  • There’s a participant with a ProjectedAddress only

请注意,IdentityProjectedAddress 的参与者算作非聊天参与者。

据我从您的代码中可以看出,您有 4 名非聊天参与者(值得注意的是,群组彩信的限制目前是 4 名参与者),所以没问题。您有一个参与者 ProjectedAddressIdentity,这很好。没有只有 ProjectedAddress.

的参与者

这留下了一个潜在的问题,即已经有一个包含这些确切参与者的现有组。

为了检查发生了什么,我现在要做几件事。

首先,仔细检查这些参与者是否正确创建,none 是否缺少 属性,尤其是带有 IdentityProjectedAddress 的参与者。

然后,检查您是否有一个包含这些参与者的现有对话对象。

如果这些检查都没有结果,请告诉我,我会升级您打开的工单。