PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, November 18, 2022

[FIXED] How to send multiple images via Twilio Programmable MMS? (PHP)

 November 18, 2022     mms, php, twilio, twilio-api, twilio-php     No comments   

Issue

I am facing a problem when I try to send multiple images in a single MMS. Even their documentation is not clear. I couldn't find an example online showing the same.


Solution

According to their documentation about MMS

Up to 10 images that together total no more than 5mb can be sent at one time. MMS is also only available in the US and Canada.

You can pass the images by using an array like so.

URL method: (urls have to be publicly accessible)

<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once '/path/to/vendor/autoload.php';

use Twilio\Rest\Client;

// Find your Account Sid and Auth Token at twilio.com/console
$sid    = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token  = "your_auth_token";
$twilio = new Client($sid, $token);

$mediaUrls = array("https://demo.twilio.com/owl.png", "url2", "url3", "url4");

$message = $twilio->messages
                  ->create("+12316851234", // to
                           array(
                               "body" => "Hello there!",
                               "from" => "+15555555555",
                               "mediaUrl" => $mediaUrls
                           )
                  );

print($message->sid);

Documentation:

https://www.twilio.com/docs/sms/api/media-resource

https://www.twilio.com/docs/sms/send-messages?code-sample=code-send-an-mms-message&code-language=PHP&code-sdk-version=5.x

More information about this here https://www.twilio.com/docs/sms/tutorials/how-to-send-sms-messages-php



Answered By - CecilMerrell aka bringrainfire
Answer Checked By - Mildred Charles (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing