I am trying to recreate the example on the Twilio site: https://www.twilio.com/docs/conversations/group-texting?code-sample=code-send-a-second-conversational-message&code-language=PHP&code-sdk-version=6.x#scenario-1-set-up-a-group-message-with-one-chat-participant-and-two-sms-participants
I have it working to a point of adding a participant and it fails.
My php script consists of:
<?php
// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require __DIR__ . '/cron/twilio-php-main/src/Twilio/autoload.php';
use Twilio\Rest\Client;
$GLOBALS = require __DIR__ . '/includes/config.php';
$twilio = new Client($GLOBALS['twSID'], $GLOBALS['twToken']);
$conversation = $twilio->conversations->v1->conversations
->create([
"friendlyName" => "RawesomePaws"
]
);
print("Created conversation.\n");
print_r($conversation . "\n");
print("conversation -> sid = ".$conversation->sid . "\n"); // CH16ac1d4633184feebc3907546cf9ccfc
print("About to add Rawesome Phone.\n");
$participant = $twilio->conversations->v1->conversations($conversation->sid)
->participants
->create([
"identity" => "Rawsome Orders",
"messagingBindingProjectedAddress" => "+MYTWILIONUMBER"
]
);
print("Added RawsomePawsOrders.\n");
print("participant -> id = " . $participant->sid . "\n");
print("About to add robs Phone.\n");
$participant = $twilio->conversations->v1->conversations($conversation->sid)
->participants
->create([
"messagingBindingAddress" => "+MYPERSONALNUMBER"
]
);
print("Added Rob.\n");
print($participant->sid);
$message = $twilio->conversations->v1->conversations($conversation->sid)
->messages
->create([
"body" => "Hi there. What did you think of the listing I sent?",
"author" => "RawesomePaws"
]
);
print("Sent Message.\n");
print($message->sid);
I get to the code above
$participant = $twilio->conversations->v1->conversations($conversation->sid)
->participants
->create([
"messagingBindingAddress" => "+MYPERSONALNUMBER"
]
);
and it fails:
Fatal error: Uncaught Twilio\Exceptions\RestException: [HTTP 409] Unable to create record: Group MMS with given participant list already exists as Conversation CHb3a38b8e12f5477c94e05c5ef6946b80 in /home/customer/www/sirota-consulting.com/public_html/PPLG/cron/twilio-php-main/src/Twilio/Version.php:88
All of the phone numbers are correct and I am getting different errors on the same line. Any suggestions or examples? I just want to create a group message so that all people notified can respond and all people in the message can get it...