1. Go to this page and download the library: Download kavenegar/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/ */
kavenegar / php example snippets
composer
"kavenegar/php": "*"
$ composer update
try{
$api = new \Kavenegar\KavenegarApi( "API Key" );
$sender = "10004346";
$message = "خدمات پیام کوتاه کاوه نگار";
$receptor = array("09123456789","09367891011");
$result = $api->Send($sender,$receptor,$message);
if($result){
foreach($result as $r){
echo "messageid = $r->messageid";
echo "message = $r->message";
echo "status = $r->status";
echo "statustext = $r->statustext";
echo "sender = $r->sender";
echo "receptor = $r->receptor";
echo "date = $r->date";
echo "cost = $r->cost";
}
}
}
catch(\Kavenegar\Exceptions\ApiException $e){
// در صورتی که خروجی وب سرویس 200 نباشد این خطا رخ می دهد
echo $e->errorMessage();
}
catch(\Kavenegar\Exceptions\HttpException $e){
// در زمانی که مشکلی در برقرای ارتباط با وب سرویس وجود داشته باشد این خطا رخ می دهد
echo $e->errorMessage();
}
/*
sample output
{
"return":
{
"status":200,
"message":"تایید شد"
},
"entries":
[
{
"messageid":8792343,
"message":"خدمات پیام کوتاه کاوه نگار",
"status":1,
"statustext":"در صف ارسال",
"sender":"10004346",
"receptor":"09123456789",
"date":1356619709,
"cost":120
},
{
"messageid":8792344,
"message":"خدمات پیام کوتاه کاوه نگار",
"status":1,
"statustext":"در صف ارسال",
"sender":"10004346",
"receptor":"09367891011",
"date":1356619709,
"cost":120
}
]
}
*/
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.