- Notifications
You must be signed in to change notification settings - Fork 57
All code snippets for v1 messages #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
20 commits Select commit Hold shift + click to select a range
7afacb0 All code snippets for v1 messages
SecondeJK b7df8ec Update messages/messenger/send-audio.php
SecondeJK ace2efb Update messages/messenger/send-file.php
SecondeJK 29d5107 Update messages/messenger/send-image.php
SecondeJK 55fe939 Update messages/messenger/send-text.php
SecondeJK 5572b04 Update messages/messenger/send-video.php
SecondeJK 1831afd Update messages/whatsapp/send-mtm.php
SecondeJK 56c730e Update messages/whatsapp/send-text.php
SecondeJK 37000e9 Update messages/whatsapp/send-video.php
SecondeJK 3a6ccbe Update messages/mms/send-mms.php
SecondeJK 675fe66 Update messages/viber/send-image.php
SecondeJK 074f898 Update messages/viber/send-text.php
SecondeJK cf2350d Update messages/whatsapp/send-audio.php
SecondeJK a7ddcd2 Update messages/whatsapp/send-button-link.php
SecondeJK d8f4d25 Update messages/whatsapp/send-button-quick-reply.php
SecondeJK 2580460 Update messages/whatsapp/send-contact.php
SecondeJK 41ca010 Update messages/whatsapp/send-file.php
SecondeJK 6467c98 Update messages/whatsapp/send-image.php
SecondeJK 1c68734 Update messages/whatsapp/send-location.php
SecondeJK 45c42bb Update messages/whatsapp/send-media-mtm.php
SecondeJK File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,21 @@ | ||
| <?php | ||
| require_once __DIR__ . '../../config.php'; | ||
| require_once __DIR__ . '../../vendor/autoload.php'; | ||
| | ||
| $keypair = new \Vonage\Client\Credentials\Keypair( | ||
| file_get_contents(VONAGE_APPLICATION_PRIVATE_KEY_PATH), | ||
| VONAGE_APPLICATION_ID | ||
| ); | ||
| | ||
| $client = new \Vonage\Client($keypair); | ||
| | ||
| $audioObject = new \Vonage\Messages\MessageObjects\AudioObject( | ||
| 'https://example.com/audio.mp3', | ||
| 'This is an audio file' | ||
| ); | ||
| | ||
| $message = new \Vonage\Messages\MessageType\Messenger\MessengerAudio( | ||
| TO_NUMBER, | ||
| FROM_NUMBER, | ||
| $audioObject | ||
| ); |
This file contains hidden or 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,20 @@ | ||
| <?php | ||
| require_once __DIR__ . '../../config.php'; | ||
| require_once __DIR__ . '../../vendor/autoload.php'; | ||
| | ||
| $keypair = new \Vonage\Client\Credentials\Keypair( | ||
| file_get_contents(VONAGE_APPLICATION_PRIVATE_KEY_PATH), | ||
| VONAGE_APPLICATION_ID | ||
| ); | ||
| | ||
| $client = new \Vonage\Client($keypair); | ||
| | ||
| $fileObject = new \Vonage\Messages\MessageObjects\FileObject( | ||
| 'https://example.com/file.pdf', | ||
| ); | ||
| | ||
| $message = new \Vonage\Messages\MessageType\Messenger\MessengerFile( | ||
| TO_NUMBER, | ||
| FROM_NUMBER, | ||
| $fileObject | ||
| ); |
This file contains hidden or 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,21 @@ | ||
| <?php | ||
| require_once __DIR__ . '../../config.php'; | ||
| require_once __DIR__ . '../../vendor/autoload.php'; | ||
| | ||
| $keypair = new \Vonage\Client\Credentials\Keypair( | ||
| file_get_contents(VONAGE_APPLICATION_PRIVATE_KEY_PATH), | ||
| VONAGE_APPLICATION_ID | ||
| ); | ||
| | ||
| $client = new \Vonage\Client($keypair); | ||
| | ||
| $imageObject = new \Vonage\Messages\MessageObjects\ImageObject( | ||
| 'https://example.com/image.jpg', | ||
| 'This is an image' | ||
| ); | ||
| | ||
| $message = new \Vonage\Messages\MessageType\Messenger\MessengerImage( | ||
| TO_NUMBER, | ||
| FROM_NUMBER, | ||
| $imageObject | ||
| ); |
This file contains hidden or 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,16 @@ | ||
| <?php | ||
| require_once __DIR__ . '../../config.php'; | ||
| require_once __DIR__ . '../../vendor/autoload.php'; | ||
| | ||
| $keypair = new \Vonage\Client\Credentials\Keypair( | ||
| file_get_contents(VONAGE_APPLICATION_PRIVATE_KEY_PATH), | ||
| VONAGE_APPLICATION_ID | ||
| ); | ||
| | ||
| $client = new \Vonage\Client($keypair); | ||
| | ||
| $message = new \Vonage\Messages\MessageType\Messenger\MessengerText( | ||
| TO_NUMBER, | ||
| FROM_NUMBER, | ||
| 'This is a text message sent using the Vonage PHP SDK' | ||
| ); |
This file contains hidden or 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,21 @@ | ||
| <?php | ||
| require_once __DIR__ . '../../config.php'; | ||
| require_once __DIR__ . '../../vendor/autoload.php'; | ||
| | ||
| $keypair = new \Vonage\Client\Credentials\Keypair( | ||
| file_get_contents(VONAGE_APPLICATION_PRIVATE_KEY_PATH), | ||
| VONAGE_APPLICATION_ID | ||
| ); | ||
| | ||
| $client = new \Vonage\Client($keypair); | ||
| | ||
| $videoObject = new \Vonage\Messages\MessageObjects\VideoObject( | ||
| 'https://example.com/video.mp4', | ||
| 'This is an video file' | ||
| ); | ||
| | ||
| $message = new \Vonage\Messages\MessageType\Messenger\MessengerVideo( | ||
| TO_NUMBER, | ||
| FROM_NUMBER, | ||
| $videoObject | ||
| ); |
This file contains hidden or 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,21 @@ | ||
| <?php | ||
| require_once __DIR__ . '../../config.php'; | ||
| require_once __DIR__ . '../../vendor/autoload.php'; | ||
| | ||
| $keypair = new \Vonage\Client\Credentials\Keypair( | ||
| file_get_contents(VONAGE_APPLICATION_PRIVATE_KEY_PATH), | ||
| VONAGE_APPLICATION_ID | ||
| ); | ||
| | ||
| $client = new \Vonage\Client($keypair); | ||
| | ||
| $image = new \Vonage\Messages\MessageObjects\ImageObject( | ||
| 'https://example.com/image.jpg', | ||
| 'A MMS image message, with caption, sent using the Vonage Messages API' | ||
| ); | ||
| | ||
| $sms = new \Vonage\Messages\MessageType\MMS\MMSImage( | ||
| TO_NUMBER, | ||
| FROM_NUMBER, | ||
| $image | ||
| ); | ||
This file contains hidden or 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,16 @@ | ||
| <?php | ||
| require_once __DIR__ . '../../config.php'; | ||
| require_once __DIR__ . '../../vendor/autoload.php'; | ||
| | ||
| $keypair = new \Vonage\Client\Credentials\Keypair( | ||
| file_get_contents(VONAGE_APPLICATION_PRIVATE_KEY_PATH), | ||
| VONAGE_APPLICATION_ID | ||
| ); | ||
| | ||
| $client = new \Vonage\Client($keypair); | ||
| | ||
| $sms = new \Vonage\Messages\MessageType\SMS\SMSText( | ||
| TO_NUMBER, | ||
| FROM_NUMBER, | ||
| 'This is an SMS sent using the Vonage PHP SDK' | ||
| ); |
This file contains hidden or 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,21 @@ | ||
| <?php | ||
| require_once __DIR__ . '../../config.php'; | ||
| require_once __DIR__ . '../../vendor/autoload.php'; | ||
| | ||
| $keypair = new \Vonage\Client\Credentials\Keypair( | ||
| file_get_contents(VONAGE_APPLICATION_PRIVATE_KEY_PATH), | ||
| VONAGE_APPLICATION_ID | ||
| ); | ||
| | ||
| $client = new \Vonage\Client($keypair); | ||
| | ||
| $imageObject = new \Vonage\Messages\MessageObjects\ImageObject( | ||
| 'https://example.com/image.jpg', | ||
| 'This is an image' | ||
| ); | ||
| | ||
| $sms = new \Vonage\Messages\MessageType\Viber\ViberImage( | ||
SecondeJK marked this conversation as resolved. Outdated Show resolved Hide resolved | ||
| TO_NUMBER, | ||
| FROM_NUMBER, | ||
| $imageObject | ||
| ); | ||
This file contains hidden or 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,16 @@ | ||
| <?php | ||
| require_once __DIR__ . '../../config.php'; | ||
| require_once __DIR__ . '../../vendor/autoload.php'; | ||
| | ||
| $keypair = new \Vonage\Client\Credentials\Keypair( | ||
| file_get_contents(VONAGE_APPLICATION_PRIVATE_KEY_PATH), | ||
| VONAGE_APPLICATION_ID | ||
| ); | ||
| | ||
| $client = new \Vonage\Client($keypair); | ||
| | ||
| $sms = new \Vonage\Messages\MessageType\Viber\ViberText( | ||
SecondeJK marked this conversation as resolved. Outdated Show resolved Hide resolved | ||
| TO_NUMBER, | ||
| FROM_NUMBER, | ||
| 'This is a text message sent using the Vonage PHP SDK' | ||
| ); | ||
This file contains hidden or 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,21 @@ | ||
| <?php | ||
| require_once __DIR__ . '../../config.php'; | ||
| require_once __DIR__ . '../../vendor/autoload.php'; | ||
| | ||
| $keypair = new \Vonage\Client\Credentials\Keypair( | ||
| file_get_contents(VONAGE_APPLICATION_PRIVATE_KEY_PATH), | ||
| VONAGE_APPLICATION_ID | ||
| ); | ||
| | ||
| $client = new \Vonage\Client($keypair); | ||
| | ||
| $audioObject = new \Vonage\Messages\MessageObjects\AudioObject( | ||
| 'https://example.com/audio.mp3', | ||
| 'This is an audio file' | ||
| ); | ||
| | ||
| $sms = new \Vonage\Messages\MessageType\WhatsApp\WhatsAppAudio( | ||
SecondeJK marked this conversation as resolved. Outdated Show resolved Hide resolved | ||
| TO_NUMBER, | ||
| FROM_NUMBER, | ||
| $audioObject | ||
| ); | ||
This file contains hidden or 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,53 @@ | ||
| <?php | ||
| require_once __DIR__ . '../../config.php'; | ||
| require_once __DIR__ . '../../vendor/autoload.php'; | ||
| | ||
| $keypair = new \Vonage\Client\Credentials\Keypair( | ||
| file_get_contents(VONAGE_APPLICATION_PRIVATE_KEY_PATH), | ||
| VONAGE_APPLICATION_ID | ||
| ); | ||
| | ||
| $client = new \Vonage\Client($keypair); | ||
| | ||
| $custom = [ | ||
| "type" => "template", | ||
| "template" => [ | ||
| "namespace" => WHATSAPP_TEMPLATE_NAMESPACE, | ||
| "name" => WHATSAPP_TEMPLATE_NAME, | ||
| "language" => ["code" => "en", "policy" => "deterministic"], | ||
| "components" => [ | ||
| [ | ||
SecondeJK marked this conversation as resolved. Show resolved Hide resolved | ||
| "type" => "header", | ||
| "parameters" => [ | ||
| [ | ||
| "type" => "image", | ||
| "image" => ["link" => HEADER_IMAGE_URL], | ||
| ], | ||
| ], | ||
| ], | ||
| [ | ||
| "type" => "body", | ||
| "parameters" => [ | ||
| ["type" => "text", "text" => "Anand"], | ||
| ["type" => "text", "text" => "Quest"], | ||
| ["type" => "text", "text" => "113-0921387"], | ||
| ["type" => "text", "text" => "23rd Nov 2019"], | ||
SecondeJK marked this conversation as resolved. Show resolved Hide resolved | ||
| ], | ||
| ], | ||
| [ | ||
| "type" => "button", | ||
| "index" => "0", | ||
| "sub_type" => "url", | ||
| "parameters" => [ | ||
| ["type" => "text", "text" => "1Z999AA10123456784"], | ||
| ], | ||
| ], | ||
| ], | ||
| ], | ||
| ]; | ||
| | ||
| $sms = new \Vonage\Messages\MessageType\WhatsApp\WhatsAppCustom( | ||
SecondeJK marked this conversation as resolved. Outdated Show resolved Hide resolved | ||
| TO_NUMBER, | ||
| FROM_NUMBER, | ||
| $custom | ||
| ); | ||
This file contains hidden or 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,58 @@ | ||
| <?php | ||
| require_once __DIR__ . '../../config.php'; | ||
| require_once __DIR__ . '../../vendor/autoload.php'; | ||
| | ||
| $keypair = new \Vonage\Client\Credentials\Keypair( | ||
| file_get_contents(VONAGE_APPLICATION_PRIVATE_KEY_PATH), | ||
| VONAGE_APPLICATION_ID | ||
| ); | ||
| | ||
| $client = new \Vonage\Client($keypair); | ||
| | ||
| $custom = [ | ||
| "type" => "template", | ||
| "template" => [ | ||
| "namespace" => WHATSAPP_TEMPLATE_NAMESPACE, | ||
| "name" => WHATSAPP_TEMPLATE_NAME, | ||
| "language" => ["code" => "en", "policy" => "deterministic"], | ||
| "components" => [ | ||
| [ | ||
| "type" => "header", | ||
| "parameters" => [["type" => "text", "text" => "12/26"]], | ||
| ], | ||
| [ | ||
| "type" => "body", | ||
| "parameters" => [ | ||
| ["type" => "text", "text" => "*Ski Trip*"], | ||
| ["type" => "text", "text" => "2019-12-26"], | ||
| [ | ||
| "type" => "text", | ||
| "text" => "*Squaw Valley Ski Resort, Tahoe*", | ||
| ], | ||
| ], | ||
| ], | ||
| [ | ||
| "type" => "button", | ||
| "sub_type" => "quick_reply", | ||
| "index" => 0, | ||
| "parameters" => [ | ||
| ["type" => "payload", "payload" => "Yes-Button-Payload"], | ||
| ], | ||
| ], | ||
| [ | ||
| "type" => "button", | ||
| "sub_type" => "quick_reply", | ||
| "index" => 1, | ||
| "parameters" => [ | ||
| ["type" => "payload", "payload" => "No-Button-Payload"], | ||
| ], | ||
| ], | ||
| ], | ||
| ], | ||
| ]; | ||
| | ||
| $sms = new \Vonage\Messages\MessageType\WhatsApp\WhatsAppCustom( | ||
SecondeJK marked this conversation as resolved. Outdated Show resolved Hide resolved | ||
| TO_NUMBER, | ||
| FROM_NUMBER, | ||
| $custom | ||
| ); | ||
This file contains hidden or 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,68 @@ | ||
| <?php | ||
| require_once __DIR__ . '../../config.php'; | ||
| require_once __DIR__ . '../../vendor/autoload.php'; | ||
| | ||
| $keypair = new \Vonage\Client\Credentials\Keypair( | ||
| file_get_contents(VONAGE_APPLICATION_PRIVATE_KEY_PATH), | ||
| VONAGE_APPLICATION_ID | ||
| ); | ||
| | ||
| $client = new \Vonage\Client($keypair); | ||
| | ||
| $custom = [ | ||
| "type" => "contacts", | ||
| "contacts" => [ | ||
| [ | ||
| "addresses" => [ | ||
| [ | ||
| "city" => "Menlo Park", | ||
| "country" => "United States", | ||
| "country_code" => "us", | ||
| "state" => "CA", | ||
| "street" => "1 Hacker Way", | ||
| "type" => "HOME", | ||
| "zip" => "94025", | ||
| ], | ||
| [ | ||
| "city" => "Menlo Park", | ||
| "country" => "United States", | ||
| "country_code" => "us", | ||
| "state" => "CA", | ||
| "street" => "200 Jefferson Dr", | ||
| "type" => "WORK", | ||
| "zip" => "94025", | ||
| ], | ||
| ], | ||
| "birthday" => "2012-08-18", | ||
| "emails" => [ | ||
| ["email" => "test@fb.com", "type" => "WORK"], | ||
| ["email" => "test@whatsapp.com", "type" => "WORK"], | ||
| ], | ||
| "name" => [ | ||
| "first_name" => "John", | ||
| "formatted_name" => "John Smith", | ||
| "last_name" => "Smith", | ||
| ], | ||
| "org" => [ | ||
| "company" => "WhatsApp", | ||
| "department" => "Design", | ||
| "title" => "Manager", | ||
| ], | ||
| "phones" => [ | ||
| ["phone" => "+1 (940) 555-1234", "type" => "HOME"], | ||
| [ | ||
| "phone" => "+1 (650) 555-1234", | ||
| "type" => "WORK", | ||
| "wa_id" => "16505551234", | ||
| ], | ||
| ], | ||
| "urls" => [["url" => "https://www.facebook.com", "type" => "WORK"]], | ||
| ], | ||
| ], | ||
| ]; | ||
| | ||
| $sms = new \Vonage\Messages\MessageType\WhatsApp\WhatsAppCustom( | ||
SecondeJK marked this conversation as resolved. Outdated Show resolved Hide resolved | ||
| TO_NUMBER, | ||
| FROM_NUMBER, | ||
| $custom | ||
| ); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.