PHP code example of pishran / ippanel-client

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

    

pishran / ippanel-client example snippets


$client = new \Pishran\IpPanel\Client('YOUR_API_KEY');

$credit = $client->getCredit();

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

$bulkId = $client->sendMessage($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);

try {
    $credit = $client->getCredit();
} catch (Exception $e) {
    echo $e->getCode(); // کد خطا
    echo $e->getMessage(); // متن توضیح خطا
}