2017 © Pedro Peláez
 

library mogreet-php

Mogreet PHP Library

image

mogreet/mogreet-php

Mogreet PHP Library

  • Tuesday, November 12, 2013
  • by jperichon
  • Repository
  • 2 Watchers
  • 3 Stars
  • 189 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 4 Forks
  • 1 Open issues
  • 1 Versions
  • 1 % Grown

The README.md

Introduction

This is a PHP wrapper for the Mogreet API. Tests and a solution to install the wrapper using a package manager are coming soon., (*1)

Installation

For now, you can use mogreet-php only by checking out this repo. Others methods will be added later., (*2)

First clone the git repo:, (*3)

git clone https://github.com/jperichon/mogreet-php.git

Then include the Client:, (*4)

require_once('/path/to/mogreet-php/Mogreet.php');

Usage examples

Create a client


require_once('/path/to/mogreet-php/Mogreet.php'); $clientId = 'xxxxx' // Your Client ID from https://developer.mogreet.com/dashboard $token = 'xxxxx' // Your token from https://developer.mogreet.com/dashboard $client = new Mogreet($clientId, $token);

Ping


$response = $client->system->ping(); print $response->message;

Send an SMS to one recipient


$response = $client->transaction->send(array( 'campaign_id' => 'xxxxx', // Your SMS campaign ID from https://developer.mogreet.com/dashboard 'to' => '9999999999', 'message' => 'This is super easy!' )); print $response->messageId;

Send an MMS to one recipient


$response = $client->transaction->send(array( 'campaign_id' => 'xxxxx', // Your MMS campaign ID from https://developer.mogreet.com/dashboard 'to' => '9999999999', 'message' => 'This is super easy!', 'content_url' => 'https://wp-uploads.mogreet.com/wp-uploads/2013/02/API-Beer-sticker-300dpi-1024x1024.jpg' )); print $response->messageId;

Upload a media file


$response = $client->media->upload(array( 'type' => 'image', 'name' => 'mogreet logo', 'file' => '/path/to/image/mogreet.png', // to ingest a file already online, use: 'url' => 'https://wp-uploads.mogreet.com/wp-uploads/2013/02/API-Beer-sticker-300dpi-1024x1024.jpg' )); print $response->media->smartUrl; print '<br/>'; print $response->media->contentId;

List all medias


$response = $client->media->listAll(); foreach($response->mediaList as $media) { print $media->contentId . ' => ' . $media->name . ' ' . $media->smartUrl . '<br />'; }

Notes

With the Response object, you can print the plain JSON response of the API call (print $response), or access directly a field (e.g: $response->message)., (*5)

Due to the keyword restriction on 'list' and the existing function 'empty()' in PHP, I changed the mappings of the following API calls:, (*6)

  • $client->*->listAll() maps to the method list
  • $client->list->pruneAll() maps to 'list.empty'

Full Documentation

The full documentation for the Mogreet API is available here, (*7)

Prerequisites

  • PHP >= 5.4
  • The PHP JSON extension

The Versions

12/11 2013

dev-master

9999999-dev https://github.com/jperichon/mogreet-php

Mogreet PHP Library

  Sources   Download

MIT

The Requires

  • php >=5.2
  • ext-curl *

 

by Jonathan Perichon

api sms messaging mms mogreet