PHP code example of mlebkowski / mobitex

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

    

mlebkowski / mobitex example snippets




$mobitex = \Mobitex\Sender::create($username, md5($password), $fromName);
try {
    $mobitex->sendMessage("+48 501 100 100", "Hello World!")
} catch (\Mobitex\Exception\PaymentRequired $e) {
    echo "Out of money";
} catch (\Mobitex\Exception\Forbidden $e) {
    echo "Invalid $fromName";
} catch (\Mobitex\Exception\RequestEntityTooLarge $e) {
    echo "Text message is too long!";
} catch (\Mobitex\Exception\Unauthorized $e) {
    echo "Invalid username or password!";
} catch (\Mobitex\Exception $e)
    echo 'Error: ' . $e->getMessage();
}



$sender = \Mobitex\Sender::create($username, md5($password), $fromName);
$sender->sendMessage("+48 501 100 100", "Hello world!", \Mobitex\Sender::TYPE_FLASH);



$sender = \Mobitex\Sender::create($username, md5($password), $fromName);
$value = $sender->checkBallance();

printf("You have %.2f PLN left \n", $value);

 

$sender = \Mobitex\Sender::create($username, md5($password), $fromName);
try {
  if (false === $sender->verifyNumber("500 100 10"))
  {
    echo "This number is invalid\n";
  } else {
    // …
  }
} catch (Mobitex\Exception $e) {
  // there still can be exceptions, invalid credentials for instance
  echo $e->getMessage() . "\n";
}