PHP code example of jalallinux / ippanel-php-rest-sdk

1. Go to this page and download the library: Download jalallinux/ippanel-php-rest-sdk 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/ */

    

jalallinux / ippanel-php-rest-sdk example snippets


$client = new \IPPanel\Client('YOUR_API_KEY');

$credit = $client->getCredit();

$originator = '5000012345'; // شماره فرستنده
$recipients = ['09123456789', '09111111111']; // شماره‌های گیرنده
$message = 'Hello world!'; // متن پیام

$bulkId = $client->send($originator, $recipients, $message);

$message = $client->getMessage($bulkId);

echo $message->status;
echo $message->cost;
echo $message->sentAt;

[$statuses, $paginationInfo] = $client->fetchStatuses($bulkId);

foreach ($statuses as $status) {
    echo "Recipient: $status->recipient, Status: $status->status";
}

echo "Total: $paginationInfo->total";

[$messages, $paginationInfo] = $client->fetchInbox();

foreach ($messages as $message) {
    echo "Received message $message->message from number $message->sender in line $message->number";
}

$pattern = $client->createPattern('Your otp is %code%.');

echo $pattern->code; // شناسه الگو

$patternCode = '12eb1cbb'; // شناسه الگو
$originator = '5000012345'; // شماره فرستنده
$recipient = '09123456789'; // شماره گیرنده
$values = ['code' => 12345];

$bulkId = $client->sendPattern($patternCode, $originator, $recipient, $values);

use IPPanel\Errors\Error;
use IPPanel\Errors\HttpException;

try{
    $bulkID = $client->send("9810001", ["98912xxxxx"], "ippanel is awesome");
} catch (Error $e) { // ippanel error
    var_dump($e->unwrap()); // بدنه خطای اصلی
    echo $e->getCode();

    if ($e->code() == ResponseCodes::ErrUnprocessableEntity) {
        echo "Unprocessable entity";
    }
} catch (HttpException $e) { // http error
    var_dump($e->getMessage()); // متن خطا
    echo $e->getCode();
}