Skip to content

feat: added new mms examples #106

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions messages/mms/send-mms-content.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?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);

$content = new \Vonage\Messages\MessageObjects\ContentObject(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code snippet spec uses an example of sending two content objects (an image and a file in the same message.

MESSAGES_IMAGE_URL,
);

$mms = new \Vonage\Messages\Channel\MMS\MMSContent(
TO_NUMBER,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
TO_NUMBER,
MESSAGES_TO_NUMBER,

FROM_NUMBER,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
FROM_NUMBER,
MMS_SENDER_ID,

$content
);

$client->messages()->send($mms);


23 changes: 23 additions & 0 deletions messages/mms/send-mms-file.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?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);

$file = new \Vonage\Messages\MessageObjects\FileObject(
MESSAGES_IMAGE_URL,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
MESSAGES_IMAGE_URL,
MESSAGES_FILE_URL,

);

$mms = new \Vonage\Messages\Channel\MMS\MMSFile(
TO_NUMBER,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
TO_NUMBER,
MESSAGES_TO_NUMBER,

FROM_NUMBER,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
FROM_NUMBER,
MMS_SENDER_ID,

$file
);

$client->messages()->send($mms);

19 changes: 19 additions & 0 deletions messages/mms/send-mms-text.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?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);

$mms = new \Vonage\Messages\Channel\MMS\MMSText(
TO_NUMBER,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
TO_NUMBER,
MESSAGES_TO_NUMBER,

FROM_NUMBER,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
FROM_NUMBER,
MMS_SENDER_ID,

'A text message sent using the Vonage SMS API'
);

$client->messages()->send($mms);