PHP code example of labsmobile / sms-php

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

    

labsmobile / sms-php example snippets


  public $username = 'myusername';
  public $token = 'mytoken';

  public function testSms()
  { 
    try {
      $message = 'Test SMS';
      $phone = ['34XXXXXXXXX'];
      $labsMobileClient = new LabsMobileClient($this->username, $this->token);
      $bodySms = new LabsMobileModelTextMessage($phone,$message);
      $labsMobileClient = $labsMobileClient->sendSms($bodySms);
      $body = $labsMobileClient->getBody();
      $json = json_decode($body);
      self::assertSame('0',$json->code);
    } catch (RestException $exception) {
      self::assertSame('Error', $exception->getStatus() ." ". $exception->getMessage());
    }
  }

  public $username = 'myusername';
  public $token = 'mytoken';

  public function testGetCredits()
  {
    try{
      $labsMobileClient = new LabsMobileClient($this->username, $this->token);
      $response = $labsMobileClient->getCredit();
      $body = $response->getBody();
      $json = json_decode($body);
      self::assertSame(0,$json->code);
    } catch(RestException $exception) {
      self::assertSame('Error', $exception->getStatus() ." ". $exception->getMessage());
    }
  }

  public $username = 'myusername';
  public $token = 'mytoken';

  public function testScheduledSendings() 
  {
    try {
      $subid="XXXXXXXXXX";
      $cmd="XXXX";
      $labsMobileClient = new LabsMobileClient($this->username, $this->token);
      $bodyScheduled = new LabsMobileModelScheduledSendings($subid, $cmd);
      $labsMobileClient = $labsMobileClient->scheduledSendings($bodyScheduled);
      $body = $labsMobileClient->getBody();
      $json = json_decode($body);
      self::assertSame(0,$json->code);
    } catch (RestException $exception) {
      self::assertSame('Error', $exception->getStatus() ." ". $exception->getMessage());
    }
  }

  public $username = 'myusername';
  public $token = 'mytoken';

  public function testCountryPrice()
  {
    try {
      $countries = ["CO","ES"];
      $labsMobileClient = new LabsMobileClient($this->username, $this->token);
      $bodyContries = new LabsMobileModelCountryPrice($countries);
      $labsMobileClient = $labsMobileClient->getpricesCountry($bodyContries);
      $body = $labsMobileClient->getBody();
      self::assertTrue(true, $body);
    } catch (RestException $exception) {
      self::assertSame('Error', $exception->getStatus() ." ". $exception->getMessage());
    }
    
  }

public $username = 'myusername';
  public $token = 'mytoken';

  public function testHlr()
  {
    try {
      $numbers = [];//[34XXXXXXXX,34XXXXXXXX]
      $labsMobileClient = new LabsMobileClient($this->username, $this->token);
      $bodyHlr = new LabsMobileModelHlrRequest(json_encode($numbers));
      $labsMobileClient = $labsMobileClient->hlrRequest($bodyHlr);
      $body = $labsMobileClient->getBody();
      $json = json_decode($body);
      self::assertSame('ok', $json->result);
    } catch (RestException $exception) {
      self::assertSame('Error', $exception->getStatus() ." ". $exception->getMessage());
    }
  }

composer 

"	"labsmobile/sms-php": "1.0.2"
}