Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
21 changes: 21 additions & 0 deletions messages/messenger/send-audio.php
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
);
20 changes: 20 additions & 0 deletions messages/messenger/send-file.php
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
);
21 changes: 21 additions & 0 deletions messages/messenger/send-image.php
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
);
16 changes: 16 additions & 0 deletions messages/messenger/send-text.php
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'
);
21 changes: 21 additions & 0 deletions messages/messenger/send-video.php
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
);
21 changes: 21 additions & 0 deletions messages/mms/send-mms.php
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
);
16 changes: 16 additions & 0 deletions messages/sms/send-sms.php
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'
);
21 changes: 21 additions & 0 deletions messages/viber/send-image.php
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(
TO_NUMBER,
FROM_NUMBER,
$imageObject
);
16 changes: 16 additions & 0 deletions messages/viber/send-text.php
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(
TO_NUMBER,
FROM_NUMBER,
'This is a text message sent using the Vonage PHP SDK'
);
21 changes: 21 additions & 0 deletions messages/whatsapp/send-audio.php
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(
TO_NUMBER,
FROM_NUMBER,
$audioObject
);
53 changes: 53 additions & 0 deletions messages/whatsapp/send-button-link.php
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" => [
[
"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"],
],
],
[
"type" => "button",
"index" => "0",
"sub_type" => "url",
"parameters" => [
["type" => "text", "text" => "1Z999AA10123456784"],
],
],
],
],
];

$sms = new \Vonage\Messages\MessageType\WhatsApp\WhatsAppCustom(
TO_NUMBER,
FROM_NUMBER,
$custom
);
58 changes: 58 additions & 0 deletions messages/whatsapp/send-button-quick-reply.php
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(
TO_NUMBER,
FROM_NUMBER,
$custom
);
68 changes: 68 additions & 0 deletions messages/whatsapp/send-contact.php
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(
TO_NUMBER,
FROM_NUMBER,
$custom
);
Loading