Download the PHP package impeto/mogreet-php without Composer
On this page you can find all versions of the php package impeto/mogreet-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package mogreet-php
Disclaimer
This is a drastically modified version of the official Mogreet PHP repo, which you can find here.
Please use that one if you are running PHP < 5.5 or if you, for some reason, do not use namespace
s in your app.
Introduction
This is a PHP wrapper for the Mogreet API.
Installation
The installation is done via Composer:
Or by cloning this repo:
git clone https://github.com/impeto/mogreet-php.git
Usage examples
Create a client
There are two ways to create a client. One is by providing the Mogreet clientId
and token
to the Mogreet\Client
class' constructor, like this:
The other way is by storing the clientId
and token
in two environment variables named MOGREET_CLIENT_ID
and MOGREET_TOKEN
respectively. Instantiating the Mogreet
class with an empty constructor will instantiate the class with these values:
Laravel Support
The package includes a Laravel ServiceProvider
as well as a Facade
for easy access to functionality in Laravel style. All you have to do is to register the Service Provider and the Facade with the Laravel App in config/app.php
file:
Then you can use it like this:
Configuration
When resolving the Mogreet\Client
object form the Laravel IoC, using the Mogreet
facade, app('mogreet')
or app(Mogreet\Client::class)
, the MogreetServiceProvider
will check for the existence of a config/mogreet.php
file. If the file exists, it will use Laravel's Config
mechanism to obtain the client_id
and token
values, like this: Config::get( 'mogreet.client_id')
and Config::get( 'mogreet.token')
. So, what you have to do is create a config/mogreet.php
file with the following contents:
If the config file does not exist, then MogreetServiceProvider
will instantiate the Client
class with an empty constructor, which means that the client_id
and token
values will be obtained from the environment variables, as explained above. In order to use this package in Laravel style, you must at the least create the environment variables MOGREET_CLIENT_ID
and MOGREET_TOKEN
; otherwise you will have to instantiate the Client
class manually as if you were using vanilla PHP.
Ping
Send an SMS to one recipient
Send an MMS to one recipient
Upload a media file
List all medias
Notes
With the Response object, you can print the plain JSON response of the API
call (echo $response
), or access directly a field (e.g: $response->message).
Due to the keyword restriction on 'list' and the existing function 'empty()' in PHP, I changed the mappings of the following API calls:
- $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
Prerequisites
- PHP >= 5.5
- The PHP JSON extension
All versions of mogreet-php with dependencies
ext-curl Version *