1. Go to this page and download the library: Download ariaieboy/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/ */
try{
$sender = "10004346"; //This is the Sender number
$message = "خدمات پیام کوتاه کاوه نگار"; //The body of SMS
$receptor = array("09361234567","09191234567"); //Receptors numbers
$result = Kavenegar::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();
}catch(\Exceptions $ex){
// در صورت بروز خطایی دیگر
echo $ex->getMessage()
}
try{
$receptor = "09123456789";
$token = "123";
$token2 = "456";
$token3 = "789";
$template="verify";
//Send null for tokens not defined in the template
//Pass token10 and token20 as parameter 6th and 7th
$result = Kavenegar::VerifyLookup($receptor, $token, $token2, $token3, $template, $type = null);
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();
}
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']);
}
}
php artisan vendor:publish
return [
'apikey' => ' ',
];
php artisan make:notification InvoicePaid
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.