1. Go to this page and download the library: Download h-o-sein/kavenegar-laravel 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/ */
h-o-sein / kavenegar-laravel 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
}
]
}
*/
class InvoicePaid extends KavenegarBaseNotification
{
}
class InvoicePaid extends KavenegarBaseNotification
{
public function __construct(Invoice $invoice)
{
$this->invoice = $invoice;
}
public function toKavenegar($notifiable)
{
return (new KavenegarMessage("فاکتور شما به شماره $invoice->id پرداخت شد."))->from('10004346');
}
}
class User extends Authenticatable
{
use Notifiable;
public function routeNotificationForKavenegar($driver, $notification = null)
{
return $this->mobile;
}
}
class InvoicePaid extends KavenegarBaseNotification
{
public function toKavenegar($notifiable)
{
return (new KavenegarMessage('فاکتور شما به شماره ۱۲۳۴ پرداخت شد.'))->from('10004346')->to('092100000');
}
}
class InvoicePaid extends KavenegarBaseNotification
{
public function toKavenegar($notifiable)
{
return (new KavenegarMessage())
->verifyLookup('verify_first',['token1','token2']);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.