Skip to content
25 changes: 25 additions & 0 deletions examples/mms-create.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

require_once(__DIR__ . '/../autoload.php');

$MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here.

$MmsMessage = new \MessageBird\Objects\MmsMessage();
$MmsMessage->originator = 'MessageBird';
$MmsMessage->recipients = array(31612345678);
$MmsMessage->subject = "Check out this cool MMS";
$MmsMessage->body = 'Have you seen this logo?';
$MmsMessage->mediaUrls = array('https://www.messagebird.com/assets/images/og/messagebird.gif');

try {
$MmsMessageResult = $MessageBird->mmsMessages->create($MmsMessage);
var_dump($MmsMessageResult);
} catch (\MessageBird\Exceptions\AuthenticateException $e) {
// That means that your accessKey is unknown
echo 'wrong login';
} catch (\MessageBird\Exceptions\BalanceException $e) {
// That means that you are out of credits, so do something about it.
echo 'no balance';
} catch (\Exception $e) {
echo $e->getMessage();
}
18 changes: 18 additions & 0 deletions examples/mms-delete.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

require_once(__DIR__ . '/../autoload.php');

$MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here.

try {
$deleted = $MessageBird->mmsMessages->delete('mms_message_id'); // id here
var_dump('Deleted: ' . $deleted);
} catch (\MessageBird\Exceptions\AuthenticateException $e) {
// That means that your accessKey is unknown
echo 'wrong login';
} catch (\MessageBird\Exceptions\BalanceException $e) {
// That means that you are out of credits, so do something about it.
echo 'no balance';
} catch (\Exception $e) {
echo $e->getMessage();
}
15 changes: 15 additions & 0 deletions examples/mms-list.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

require_once(__DIR__ . '/../autoload.php');

$MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here.

try {
$MmsList = $MessageBird->mmsMessages->getList(array('offset' => 0, 'limit' => 30));
var_dump($MmsList);
} catch (\MessageBird\Exceptions\AuthenticateException $e) {
// That means that your accessKey is unknown
echo 'wrong login';
} catch (\Exception $e) {
var_dump($e->getMessage());
}
15 changes: 15 additions & 0 deletions examples/mms-view.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

require_once(__DIR__ . '/../autoload.php');

$MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here.

try {
$MmsResult = $MessageBird->mmsMessages->read('mms_message_id'); // Set a MMS Message id
var_dump($MmsResult);
} catch (\MessageBird\Exceptions\AuthenticateException $e) {
// That means that your accessKey is unknown
echo 'wrong login';
} catch (\Exception $e) {
var_dump($e->getMessage());
}
6 changes: 6 additions & 0 deletions src/MessageBird/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ class Client
*/
public $lookupHlr;

/**
* @var Resources\MmsMessages
*/
public $mmsMessages;

/**
* @var Resources\Chat\Message
*/
Expand Down Expand Up @@ -125,6 +130,7 @@ public function __construct($accessKey = null, Common\HttpClient $httpClient = n
$this->voicemessages = new Resources\VoiceMessage($this->HttpClient);
$this->lookup = new Resources\Lookup($this->HttpClient);
$this->lookupHlr = new Resources\LookupHlr($this->HttpClient);
$this->mmsMessages = new Resources\MmsMessages($this->HttpClient);
$this->contacts = new Resources\Contacts($this->HttpClient);
$this->groups = new Resources\Groups($this->HttpClient);
$this->chatMessages = new Resources\Chat\Message($this->ChatAPIHttpClient);
Expand Down
142 changes: 142 additions & 0 deletions src/MessageBird/Objects/MmsMessage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
<?php

namespace MessageBird\Objects;

/**
* Class MmsMessage
*
* @package MessageBird\Objects
*/
class MmsMessage extends Base {

/**
* An unique random ID which is created on the MessageBird
* platform and is returned upon creation of the object.
*
* @var string
*/
protected $id;

/**
* The url of the created object.
*
* @var string
*/
protected $href;

/**
* Tells you if the message is sent or received.
* mt: mobile terminated (sent to mobile)
* mo: mobile originated (received from mobile)
*
* @var string
*/
public $direction = 'mt';

/**
* The sender of the MMS message. This can be a telephone number
* (including country code) or an alphanumeric string. In case
* of an alphanumeric string, the maximum length is 11 characters.
*
* @var string
*/
public $originator;

/**
* An array of recipients.
*
* @var array
*/
public $recipients = array();

/**
* The subject of MMS the message.
*
* @var string
*/
public $subject;

/**
* The body of the MMS message.
*
* @var string
*/
public $body;

/**
* The array of URL's to the media attachments that you want to
* send as part of the MMS message.
*
* @var array
*/
public $mediaUrls = array();

/**
* A client reference.
*
* @var string
*/
public $reference;

/**
* The scheduled date and time of the message in RFC3339 format (Y-m-d\TH:i:sP)
*
* @var string
*/
public $scheduledDatetime;

/**
* The date and time of the creation of the message in RFC3339 format (Y-m-d\TH:i:sP)
* @var string
*/
public $createdDatetime;


/**
* Get the created id
*
* @return string
*/
public function getId() {
return $this->id;
}

/**
* Get the created href
*
* @return string
*/
public function getHref() {
return $this->href;
}

/**
* Get the $createdDatetime value
*
* @return string
*/
public function getCreatedDatetime() {
return $this->createdDatetime;
}

/**
* @param $object
*
* @return $this|void
*/
public function loadFromArray($object)
{
parent::loadFromArray($object);

if (!empty($this->recipients->items)) {
foreach($this->recipients->items as &$item) {
$Recipient = new Recipient();
$Recipient->loadFromArray($item);

$item = $Recipient;
}
}

return $this;
}
}
25 changes: 25 additions & 0 deletions src/MessageBird/Resources/MmsMessages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace MessageBird\Resources;

use MessageBird\Common;
use MessageBird\Objects;

/**
* Class MmsMessages
*
* @package MessageBird\Resources
*/
class MmsMessages extends Base {

/**
* @param Common\HttpClient $HttpClient
*/
public function __construct(Common\HttpClient $HttpClient)
{
$this->setObject(new Objects\MmsMessage());
$this->setResourceName('mms');

parent::__construct($HttpClient);
}
}
7 changes: 7 additions & 0 deletions tests/integration/BaseTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
<?php
class BaseTest extends PHPUnit_Framework_TestCase
{
/** @var \MessageBird\Client */
protected $client;

/** @var PHPUnit_Framework_MockObject_MockObject */
protected $mockClient;

public function setUp()
{
$this->mockClient = $this->getMockBuilder("\MessageBird\Common\HttpClient")->setConstructorArgs(array("fake.messagebird.dev"))->getMock();
$this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient);
}

public function testClientConstructor()
Expand Down
Loading