PHP code example of impeto / mogreet-php

1. Go to this page and download the library: Download impeto/mogreet-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

impeto / mogreet-php example snippets


     composer 


...
use Mogreet\Client;
...

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

     $client = new Mogreet\Client();

     ...
     'providers' => [
          ...
          Mogreet\Laravel\MogreetServiceProvider::class,
          ...
     ],
     ...
     'aliases' => [
          ...
          'Mogreet' => Mogreet\Laravel\MogreetFacade::class,
          ...
     ]

     ...
     $result = Mogreet::system()->ping();
     //or
     $result = app('mogreet')->system()->ping();
     //or
     $result = app(Mogreet\Client::class)->system()->ping();
     return $result->status;


return [
     'client_id' => 'your client id here',
     'token' => 'your token here'
];


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


$response = $client->transaction()->send(array(
    'campaign_id' => 'xxxxx', // Your SMS campaign ID from https://developer.mogreet.com/dashboard
    'to' => '9999999999',
    'message' => 'Hello form Mogreet API!'
));
echo $response->messageId;


$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'
));
echo $response->messageId;


$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'
));
echo $response->media->smartUrl;
echo '<br/>';
echo $response->media->contentId;


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