PHP code example of joshuachinemezu / smsglobal-laravel

1. Go to this page and download the library: Download joshuachinemezu/smsglobal-laravel 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/ */

    

joshuachinemezu / smsglobal-laravel example snippets


'providers' => [
    ...
    JoshuaChinemezu\SmsGlobal\SmsGlobalServiceProvider::class,
    ...
]

'aliases' => [
    ...
    'SmsGlobal' => JoshuaChinemezu\SmsGlobal\Facades\SmsGlobal::class,
    ...
]



return [

    /**
     * Hash algorithm to use with hash_hmac. Use hash_algos() to get a list of
     * supported algos. SMSGlobal uses sha256
     */

    'hashAlgo' => env('SMSGLOBAL_HASH_ALGO', 'sha256'),


    /**
     * API Key: Your SmsGlobal APIKey. Get it from https://mxt.smsglobal.com/integrations
     *
     */
    'apiKey' => env('SMSGLOBAL_API_KEY'),

    /**
     * Secret Key: Your SmsGlobal secretKey. Sign up on https://www.smsglobal.com/mxt-sign-up/ to get one from your integrations page
     *
     */
    'secretKey' => env('SMSGLOBAL_SECRET_KEY'),

    /**
     * Host name
     *
     */
    'host' => env('SMSGLOBAL_HOST', 'api.smsglobal.com'),

    /**
     * Protocol
     *
     */
    'protocol' => env('SMSGLOBAL_PROTOCOL', 'https'),

    /**
     * Port
     *
     */
    'port' => env('SMSGLOBAL_PORT', 443),

    /**
     * API Version
     *
     */
    'apiVersion' => env('SMSGLOBAL_API_VERSION', 'v2'),

    /**
     * Debug mode
     *
     */
    'debug' => env('SMSGLOBAL_DEBUG', false),
];

SMSGLOBAL_API_KEY=xxxxxxxxxxxxx
SMSGLOBAL_SECRET_KEY=xxxxxxxxxxxxx



namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use JoshuaChinemezu\SmsGlobal\RestApi\RestApiClient;

class SmsController extends Controller
{

    /**
     * Get
     * @return json
     */
    public function getSmsGlobalDedicatedNumbers()
    {
        $smsglobal = new RestApiClient;
        return $smsglobal->getAllDedicatedNumbers();
    }

     /**
     * This method can be implemented in a Queue - this is just an example
     * @return json
     */
    public function sendSms()
    {
        $smsglobal = new RestApiClient;
        return $smsglobal->sendMessage([
            "destination" => "xxxx", // Destination mobile number. 3-15 digits
            "message" => "Hello", // The SMS message. If longer than 160 characters (GSM) or 70 characters (Unicode), splits into multiple SMS
        ]); // Check https://www.smsglobal.com/rest-api/ for more options
    }
}



/**
 *  Get the auto top-up information associated to the authenticated account.
 */
$smsglobal->getAutoTopUpInfo();

/**
 * Alternatively, use the helper.
 */
smsglobal()->getAutoTopUpInfo();


/**
 *  Delete a contact
 * @param integer $id
 * @return json
 */
$smsglobal->deleteContact($id);

/**
 * Alternatively, use the helper.
 */
smsglobal()->deleteContact($id);


/**
 *  Get the contact as identified by the given id.
 * @param integer $id
 * @return json
 */
$smsglobal->getContactByID($id);

/**
 * Alternatively, use the helper.
 */
smsglobal()->getContactByID($id);


/**
 *  Update the contact as identified by the given id. You can only update the
 * default fields associated with each contact.
 * @param integer $id
 * @return json
 */
$smsglobal->updateContactByID($id);

/**
 * Alternatively, use the helper.
 */
smsglobal()->updateContactByID($id);


/**
 *  Get a list of all contact groups.
 * @param array $queryOptions
 * See https://www.smsglobal.com/rest-api/ - /v2/group - GET
 * @return json
 */
$smsglobal->getAllContactGroups($queryOptions);

/**
 * Alternatively, use the helper.
 */
smsglobal()->getAllContactGroups($queryOptions);


/**
 *  Create a new contact group.
 * @param array $formData
 * See https://www.smsglobal.com/rest-api/ - /v2/group - POST
 * @return json
 * $formData = [
 *      "name" => "Joshua Group",
 *      "keyword" => "smsgroup",
 *      "defaultOrigin" => "",
 *      "isGlobal" => false,
 *  ]
 */
$smsglobal->createContactGroup($formData);

/**
 * Alternatively, use the helper.
 */
smsglobal()->createContactGroup($formData);


/**
 *  Create a new contact group.
 * @param integer $groupId
 * @param array $formData
 * @return json
 * $formData = [
 *      "msisdn" => "Joshua Contact",
 *      "givenName" => "Joshua",
 * See on https://www.smsglobal.com/rest-api/  - group/{groupId}/contact - POST
 *  ]
 */
$smsglobal->createContact($groupId, $formData);

/**
 * Alternatively, use the helper.
 */
smsglobal()->createContact($groupId, $formData);


/**
 *  Get a list of all contacts in a group.
 * @param integer $groupId
 * @param array $filters
 * @return json
 * $filters = [
 *      "offset" => 1,
 *      "limit" => 20,
 *      "sort" => "id"
 *  ]
 */
$smsglobal->getContactsByGroupID($groupId, $filters);

/**
 * Alternatively, use the helper.
 */
smsglobal()->getContactsByGroupID($groupId, $filters);


/**
 *  Delete a contact group
 * @param integer $id
 * @return json
 */
$smsglobal->deleteContactGroup($id);

/**
 * Alternatively, use the helper.
 */
smsglobal()->deleteContactGroup($id);


/**
 *  Get the contact group as identified by the given id.
 * @param integer $id
 * @return json
 */
$smsglobal->getContactGroupByID($id);

/**
 * Alternatively, use the helper.
 */
smsglobal()->getContactGroupByID($id);


/**
 *  Update fields of a group as identified by the given id
 * @param integer $id
 * @param array $param
 *  $param = [
 *     "name" => "Joshua Group",
 *      "keyword" => "",
 *       ... More options on https://www.smsglobal.com/rest-api/
 *   ]
 * @return json
 */
$smsglobal->updateGroupFieldByID($id, $param);

/**
 * Alternatively, use the helper.
 */
smsglobal()->updateGroupFieldByID($id, $param);


/**
 *  View list of dedicated numbers
 * @return json
 */
$smsglobal->getAllDedicatedNumbers();

/**
 * Alternatively, use the helper.
 */
smsglobal()->getAllDedicatedNumbers();


/**
 *  View list of opted out numbers
 * @param array $filters
 *  $filters = [
 *     "phoneNumber" => xxx,
 *      "offset" => 1,
 *      "limit" => 20,
 *   ]
 * @return json
 */
$smsglobal->getAllOptedOutNumbers($filters);

/**
 * Alternatively, use the helper.
 */
smsglobal()->getAllOptedOutNumbers($filters);


/**
 *  Opt out mobile numbers
 * @param array $mobileNumbers
 *  $mobileNumbers = [xxx. xxx, xxx]
 * @return json
 */
$smsglobal->optOutMobileNumbers($mobileNumbers);

/**
 * Alternatively, use the helper.
 */
smsglobal()->optOutMobileNumbers($mobileNumbers);


/**
 *  Validate mobile numbers for opt out
 * @param array $mobileNumbers
 *  $mobileNumbers = [xxx. xxx, xxx]
 * @return json
 */
$smsglobal->validateOptOutMobileNumbers($mobileNumbers);

/**
 * Alternatively, use the helper.
 */
smsglobal()->validateOptOutMobileNumbers($mobileNumbers);



/**
 *  Opt in a mobile number
 * @param integer $mobileNumber
 *  $mobileNumbers = xxx
 * @return json
 */
$smsglobal->optInMobileNumber($mobileNumber);

/**
 * Alternatively, use the helper.
 */
smsglobal()->optInMobileNumber($mobileNumber);


/**
 *  Opt in a mobile number
 * @param integer $mobileNumber
 *  $mobileNumbers = xxx
 * @return json
 */
$smsglobal->optInMobileNumber($mobileNumber);

/**
 * Alternatively, use the helper.
 */
smsglobal()->optInMobileNumber($mobileNumber);


/**
 *  View list of shared pools
 * @return json
 */
$smsglobal->getAllSharedPools();

/**
 * Alternatively, use the helper.
 */
smsglobal()->getAllSharedPools();


/**
 *  View details of a shared pool
 * @param integer $id
 * @return json
 */
$smsglobal->getSharedPoolByID($id);

/**
 * Alternatively, use the helper.
 */
smsglobal()->getSharedPoolByID($id);



/**
 *  View list of outgoing messages
 * @param array $filters
 *  $filters = [
 *      "offset" => 1,
 *      "limit" => 20,
 *      "status" => "delivered",
 *      ... More option https://www.smsglobal.com/rest-api/ - /v2/sms - GET
 *   ]
 * @return json
 */
$smsglobal->getAllOutGoingMessage($filters);

/**
 * Alternatively, use the helper.
 */
smsglobal()->getAllOutGoingMessage($filters);


/**
 *  View list of outgoing messages
 * @param array $postData
 *  $postData = [
 *      "message" => "Hello",
 *      ... More option https://www.smsglobal.com/rest-api/ - /v2/sms - POST
 *   ]
 * @return json
 */
$smsglobal->sendMessage($postData);

/**
 * Alternatively, use the helper.
 */
smsglobal()->sendMessage($postData);


/**
 *  Delete outgoing message
 * @param integer $id
 * @return json
 */
$smsglobal->deleteOutGoingMessage($id);

/**
 * Alternatively, use the helper.
 */
smsglobal()->deleteOutGoingMessage($id);


/**
 * View details of an outgoing message
 * @param integer $id
 * @return json
 */
$smsglobal->getOutGoingMessageByID($id);

/**
 * Alternatively, use the helper.
 */
smsglobal()->getOutGoingMessageByID($id);


/**
 * View list of incoming messages
 * @param arrray $filters'
 *  $filters = [
 *      "offset" => 1,
 *      "limit" => 20,
 *      ... More option https://www.smsglobal.com/rest-api/ - /v2/sms-incoming - GET
 *   ]
 * @return json
 */
$smsglobal->getAllIncomingMessage($filters);

/**
 * Alternatively, use the helper.
 */
smsglobal()->getAllIncomingMessage($filters);


/**
 * View list of incoming messages
 * @param arrray $filters'
 *  $filters = [
 *      "offset" => 1,
 *      "limit" => 20,
 *      ... More option https://www.smsglobal.com/rest-api/ - /v2/sms-incoming - GET
 *   ]
 * @return json
 */
$smsglobal->getAllIncomingMessage($filters);

/**
 * Alternatively, use the helper.
 */
smsglobal()->getAllIncomingMessage($filters);


/**
 * Delete incoming message
 * @param integer $id
 * @return json
 */
$smsglobal->deleteIncomingMessage($id);

/**
 * Alternatively, use the helper.
 */
smsglobal()->deleteIncomingMessage($id);


/**
 * View details of an incoming message
 * @param integer $id
 * @return json
 */
$smsglobal->getIncomingMessageByID($id);

/**
 * Alternatively, use the helper.
 */
smsglobal()->getIncomingMessageByID($id);


/**
 * Get the authenticated account's billing details.
 * @return json
 */
$smsglobal->getBillingDetails();

/**
 * Alternatively, use the helper.
 */
smsglobal()->getBillingDetails();


/**
 * Update the authenticated account's billing details.
 * @param array $params
 * See https://www.smsglobal.com/rest-api/ - /v2/user/billing-details - PUT
 * @return json
 */
$smsglobal->updateBillingDetails($params);

/**
 * Alternatively, use the helper.
 */
smsglobal()->updateBillingDetails($params);


/**
 * Get the authenticated account's contact details.
 * @return json
 */
$smsglobal->getContactDetails();

/**
 * Alternatively, use the helper.
 */
smsglobal()->getContactDetails();


/**
 * Get the authenticated account's billing details.
 * @param array $params
 * See https://www.smsglobal.com/rest-api/ - /v2/user/billing-details - PUT
 * @return json
 */
$smsglobal->updateContactDetails($params);

/**
 * Alternatively, use the helper.
 */
smsglobal()->updateContactDetails($params);


/**
 * View the account balance
 * @return json
 */
$smsglobal->getBalance();

/**
 * Alternatively, use the helper.
 */
smsglobal()->getBalance();


/**
 * Get the low balance alerts information associated to the authenticated
 * account.
 * * @return json
 */
$smsglobal->getLowBalanceAlert();

/**
 * Alternatively, use the helper.
 */
smsglobal()->getLowBalanceAlert();


/**
 * Update the authenticated account's low balance alerts information.
 * @param array $params
 * See https://www.smsglobal.com/rest-api/ - /v2/user/low-balance-alerts - PUT
 * * @return json
 */
$smsglobal->updateLowAlertBalance($params);

/**
 * Alternatively, use the helper.
 */
smsglobal()->updateLowAlertBalance($params);


/**
 * Create sub account
 * @param array $params
 * See https://www.smsglobal.com/rest-api/ - /v2/user/low-balance-alerts - POST
 * * @return json
 */
$smsglobal->createSubAccount($params);

/**
 * Alternatively, use the helper.
 */
smsglobal()->createSubAccount($params);


/**
 * Get the authenticated account's verified numbers.
 * @param array $params
 * See https://www.smsglobal.com/rest-api/ - /v2/user/verified-numbers - GET
 * * @return json
 */
$smsglobal->getVerifiedNumbers($params);

/**
 * Alternatively, use the helper.
 */
smsglobal()->getVerifiedNumbers($params);

bash
php artisan vendor:publish --provider="JoshuaChinemezu\SmsGlobal\SmsGlobalServiceProvider"