-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from mariuspot/master
Add WhatsApp Sandbox support to Conversations API
- Loading branch information
Showing
3 changed files
with
47 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
// Initiates a conversation by sending a first message. This example uses a | ||
// plain text message, but other types are also available. See the | ||
// conversations-messages-create examples. | ||
|
||
require(__DIR__ . '/../../autoload.php'); | ||
|
||
// Set your own API access key here. | ||
// Create a client with WhatsApp sandbox enabled. | ||
$messageBird = new \MessageBird\Client('YOUR_ACCESS_KEY', null, [\MessageBird\Client::ENABLE_CONVERSATIONSAPI_WHATSAPP_SANDBOX]); | ||
|
||
// Use WhatsApp sandbox channel as normal. | ||
|
||
$content = new \MessageBird\Objects\Conversation\Content(); | ||
$content->text = 'Hello world'; | ||
|
||
$message = new \MessageBird\Objects\Conversation\Message(); | ||
$message->channelId = 'WHATSAPP_SANDBOX_CHANNEL_ID'; | ||
$message->content = $content; | ||
$message->to = 'RECIPIENT'; // Channel-specific, e.g. MSISDN for SMS. | ||
$message->type = 'text'; | ||
|
||
try { | ||
$conversation = $messageBird->conversations->start($message); | ||
|
||
var_dump($conversation); | ||
} catch (\Exception $e) { | ||
echo sprintf("%s: %s", get_class($e), $e->getMessage()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters