webazin/kavenegar

KaveNegar.com webservice for Laravel

0.0.3 2022-12-06 07:00 UTC

This package is auto-updated.

Last update: 2024-12-06 11:36:59 UTC


README

#KaveNegar

Installation

Step 1: Run this command:

composer require webazin/kavenegar

Step 2: Add provider in config/app.php

'providers' => [
    ...
    webazin\KaveNegar\KaveNegarServiceProvider::class, //<--add this line at the end of provider array
]

Step 3: Run this command:

php artisan vendor:publish

Configuration file is placed in config/kavenegar.php , open it and enter your kavenegar.com api token

Usage

use the kavenegar class on your Controller:

use webazin/KaveNegar/SMS;

a basic example of send a sms

public function sms(SMS $sms)
    {
        try {
            $sender = "10006707323323";
            $message = "Hello Api";
            $receptor = ['0937XXXXXXX', '0933XXXXXXX']; // reciver phone number as a array
            $date = null;
            $type = 1;
            $localIds = ['1','2'];
            $result = $sms->Send($receptor, $sender, $message, $date, $type, $localIds);
            dd($result); // or anything do with $result
        } catch (ApiException $e) {
            return $e->errorMessage();
        } catch (HttpException $e) {
            return $e->errorMessage();
        }
    }
    

a basic example of make a call

  
public function call(SMS $sms){
   try {
	$receptor = $mobile;
	$message  = "call message";
	$date     = "";
	$localid  = "";
	$result   = $sms->CallMakeTTS( $receptor , $message , $date , $localid );    
        }
    catch ( HttpException $e ) {
	echo $e->errorMessage();
	}
 }
                

for more info see Kavenegar.com Official Document

وب آذین