allow vendord
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m3s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 16s
Build, Push and Deploy / deploy-staging (push) Successful in 32s
Build, Push and Deploy / deploy-production (push) Has been skipped
Build, Push and Deploy / cleanup (push) Successful in 1s

This commit is contained in:
2026-03-30 14:54:57 +07:00
parent 66aed7c4e8
commit b5e3a778ce
21316 changed files with 2777892 additions and 13 deletions

148
vendor/kavenegar/php/README.md vendored Normal file
View File

@@ -0,0 +1,148 @@
# kavenegar-PHP
# <a href="http://kavenegar.com/rest.html">Kavenegar RESTful API Document</a>
If you need to future information about API document Please visit RESTful Document
## Installation
<p>
First of all, You need to make an account on Kavenegar from <a href="https://panel.kavenegar.com/Client/Membership/Register">Here</a>
</p>
<p>
After that you just need to pick API-KEY up from <a href="http://panel.kavenegar.com/Client/setting/index">My Account</a> section.
</p>
<hr>
Use in these ways :
```php
composer require kavenegar/php
```
or add
```php
"kavenegar/php": "*"
```
And run following command to download extension using **composer**
```php
$ composer update
```
Usage
-----
Well, There is an example to Send SMS by PHP.
```php
require __DIR__ . '/vendor/autoload.php';
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
}
]
}
*/
```
## Contribution
Bug fixes, docs, and enhancements welcome! Please let us know <a href="mailto:support@kavenegar.com?Subject=SDK" target="_top">support@kavenegar.com</a>
<hr>
<div dir='rtl'>
## راهنما
### معرفی سرویس کاوه نگار
کاوه نگار یک وب سرویس ارسال و دریافت پیامک و تماس صوتی است که به راحتی میتوانید از آن استفاده نمایید.
### ساخت حساب کاربری
اگر در وب سرویس کاوه نگار عضو نیستید میتوانید از [لینک عضویت](http://panel.kavenegar.com/client/membership/register) ثبت نام و اکانت آزمایشی برای تست API دریافت نمایید.
### مستندات
برای مشاهده اطلاعات کامل مستندات [وب سرویس پیامک](http://kavenegar.com/وب-سرویس-پیامک.html) به صفحه [مستندات وب سرویس](http://kavenegar.com/rest.html) مراجعه نمایید.
### راهنمای فارسی
در صورتی که مایل هستید راهنمای فارسی کیت توسعه کاوه نگار را مطالعه کنید به صفحه [کد ارسال پیامک](http://kavenegar.com/sdk.html) مراجعه نمایید.
### اطالاعات بیشتر
برای مطالعه بیشتر به صفحه معرفی
[وب سرویس اس ام اس ](http://kavenegar.com)
کاوه نگار
مراجعه نمایید .
اگر در استفاده از کیت های سرویس کاوه نگار مشکلی یا پیشنهادی داشتید ما را با یک Pull Request یا ارسال ایمیل به support@kavenegar.com خوشحال کنید.
##
![http://kavenegar.com](http://kavenegar.com/public/images/logo.png)
[http://kavenegar.com](http://kavenegar.com)
</div>

23
vendor/kavenegar/php/composer.json vendored Normal file
View File

@@ -0,0 +1,23 @@
{
"name": "kavenegar/php",
"type": "library",
"description": "A PHP wrapper for Kavenegar's API",
"keywords": ["kavenegar", "sms", "api"],
"homepage": "http://github.com/Kavenegar/kavenegar-php",
"license": "MIT",
"authors": [
{
"name": "Kavenegar API Team",
"email": "support@kavenegar.com"
}
],
"require": {
"php": ">=5.4.0"
},
"autoload": {
"psr-4": {
"Kavenegar\\": "src/"
}
},
"minimum-stability" : "stable"
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Kavenegar\Enums;
abstract class ApiLogs extends General {
const Justforfault = "justforfault";
const Enabled = "enabled";
const Disabled = "disabled";
}
?>

View File

@@ -0,0 +1,9 @@
<?php
namespace Kavenegar\Enums;
abstract class General {
const Enabled = "enabled";
const Disabled = "disabled";
}
?>

View File

@@ -0,0 +1,13 @@
<?php
namespace Kavenegar\Exceptions;
class ApiException extends BaseRuntimeException
{
public function getName()
{
return 'ApiException';
}
}
?>

View File

@@ -0,0 +1,19 @@
<?php
namespace Kavenegar\Exceptions;
class BaseRuntimeException extends \RuntimeException
{
public function getName()
{
return 'BaseRuntimeException';
}
public function __construct($message, $code=0) {
parent::__construct($message, $code);
}
public function errorMessage(){
return "\r\n".$this->getName() . "[{$this->code}] : {$this->message}\r\n";
}
}
?>

View File

@@ -0,0 +1,13 @@
<?php
namespace Kavenegar\Exceptions;
class HttpException extends BaseRuntimeException
{
public function getName()
{
return 'HttpException';
}
}
?>

View File

@@ -0,0 +1,294 @@
<?php
namespace Kavenegar;
use Kavenegar\Exceptions\ApiException;
use Kavenegar\Exceptions\HttpException;
use Kavenegar\Exceptions\RuntimeException;
use Kavenegar\Enums\ApiLogs ;
use Kavenegar\Enums\General;
class KavenegarApi
{
const APIPATH = "%s://api.kavenegar.com/v1/%s/%s/%s.json/";
const VERSION = "1.2.2";
public function __construct($apiKey,$insecure=false)
{
if (!extension_loaded('curl')) {
die('cURL library is not loaded');
exit;
}
if (is_null($apiKey)) {
die('apiKey is empty');
exit;
}
$this->apiKey = trim($apiKey);
$this->insecure = $insecure;
}
protected function get_path($method, $base = 'sms')
{
return sprintf(self::APIPATH,$this->insecure==true ? "http": "https", $this->apiKey, $base, $method);
}
protected function execute($url, $data = null)
{
$headers = array(
'Accept: application/json',
'Content-Type: application/x-www-form-urlencoded',
'charset: utf-8'
);
$fields_string = "";
if (!is_null($data)) {
$fields_string = http_build_query($data);
}
$handle = curl_init();
curl_setopt($handle, CURLOPT_URL, $url);
curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($handle, CURLOPT_POST, true);
curl_setopt($handle, CURLOPT_POSTFIELDS, $fields_string);
$response = curl_exec($handle);
$code = curl_getinfo($handle, CURLINFO_HTTP_CODE);
$content_type = curl_getinfo($handle, CURLINFO_CONTENT_TYPE);
$curl_errno = curl_errno($handle);
$curl_error = curl_error($handle);
if ($curl_errno) {
throw new HttpException($curl_error, $curl_errno);
}
$json_response = json_decode($response);
if ($code != 200 && is_null($json_response)) {
throw new HttpException("Request have errors", $code);
} else {
$json_return = $json_response->return;
if ($json_return->status != 200) {
throw new ApiException($json_return->message, $json_return->status);
}
return $json_response->entries;
}
}
public function Send($sender, $receptor, $message, $date = null, $type = null, $localid = null)
{
if (is_array($receptor)) {
$receptor = implode(",", $receptor);
}
if (is_array($localid)) {
$localid = implode(",", $localid);
}
$path = $this->get_path("send");
$params = array(
"receptor" => $receptor,
"sender" => $sender,
"message" => $message,
"date" => $date,
"type" => $type,
"localid" => $localid
);
return $this->execute($path, $params);
}
public function SendArray($sender, $receptor, $message, $date = null, $type = null, $localmessageid = null)
{
if (!is_array($receptor)) {
$receptor = (array) $receptor;
}
if (!is_array($sender)) {
$sender = (array) $sender;
}
if (!is_array($message)) {
$message = (array) $message;
}
$repeat = count($receptor);
if (!is_null($type) && !is_array($type)) {
$type = array_fill(0, $repeat, $type);
}
if (!is_null($localmessageid) && !is_array($localmessageid)) {
$localmessageid = array_fill(0, $repeat, $localmessageid);
}
$path = $this->get_path("sendarray");
$params = array(
"receptor" => json_encode($receptor),
"sender" => json_encode($sender),
"message" => json_encode($message),
"date" => $date,
"type" => json_encode($type),
"localmessageid" => json_encode($localmessageid)
);
return $this->execute($path, $params);
}
public function Status($messageid)
{
$path = $this->get_path("status");
$params = array(
"messageid" => is_array($messageid) ? implode(",", $messageid) : $messageid
);
return $this->execute($path,$params);
}
public function StatusLocalMessageId($localid)
{
$path = $this->get_path("statuslocalmessageid");
$params = array(
"localid" => is_array($localid) ? implode(",", $localid) : $localid
);
return $this->execute($path, $params);
}
public function Select($messageid)
{
$params = array(
"messageid" => is_array($messageid) ? implode(",", $messageid) : $messageid
);
$path = $this->get_path("select");
return $this->execute($path, $params);
}
public function SelectOutbox($startdate, $enddate, $sender)
{
$path = $this->get_path("selectoutbox");
$params = array(
"startdate" => $startdate,
"enddate" => $enddate,
"sender" => $sender
);
return $this->execute($path, $params);
}
public function LatestOutbox($pagesize, $sender)
{
$path = $this->get_path("latestoutbox");
$params = array(
"pagesize" => $pagesize,
"sender" => $sender
);
return $this->execute($path, $params);
}
public function CountOutbox($startdate, $enddate, $status = 0)
{
$path = $this->get_path("countoutbox");
$params = array(
"startdate" => $startdate,
"enddate" => $enddate,
"status" => $status
);
return $this->execute($path, $params);
}
public function Cancel($messageid)
{
$path = $this->get_path("cancel");
$params = array(
"messageid" => is_array($messageid) ? implode(",", $messageid) : $messageid
);
return $this->execute($path,$params);
}
public function Receive($linenumber, $isread = 0)
{
$path = $this->get_path("receive");
$params = array(
"linenumber" => $linenumber,
"isread" => $isread
);
return $this->execute($path, $params);
}
public function CountInbox($startdate, $enddate, $linenumber, $isread = 0)
{
$path = $this->get_path("countinbox");
$params = array(
"startdate" => $startdate,
"enddate" => $enddate,
"linenumber" => $linenumber,
"isread" => $isread
);
return $this->execute($path, $params);
}
public function CountPostalcode($postalcode)
{
$path = $this->get_path("countpostalcode");
$params = array(
"postalcode" => $postalcode
);
return $this->execute($path, $params);
}
public function SendbyPostalcode($sender,$postalcode,$message, $mcistartindex, $mcicount, $mtnstartindex, $mtncount, $date)
{
$path = $this->get_path("sendbypostalcode");
$params = array(
"postalcode" => $postalcode,
"sender" => $sender,
"message" => $message,
"mcistartindex" => $mcistartindex,
"mcicount" => $mcicount,
"mtnstartindex" => $mtnstartindex,
"mtncount" => $mtncount,
"date" => $date
);
return $this->execute($path, $params);
}
public function AccountInfo()
{
$path = $this->get_path("info", "account");
return $this->execute($path);
}
public function AccountConfig($apilogs, $dailyreport, $debug, $defaultsender, $mincreditalarm, $resendfailed)
{
$path = $this->get_path("config", "account");
$params = array(
"apilogs" => $apilogs,
"dailyreport" => $dailyreport,
"debug" => $debug,
"defaultsender" => $defaultsender,
"mincreditalarm" => $mincreditalarm,
"resendfailed" => $resendfailed
);
return $this->execute($path, $params);
}
public function VerifyLookup($receptor, $token, $token2, $token3, $template, $type = null)
{
$path = $this->get_path("lookup", "verify");
$params = array(
"receptor" => $receptor,
"token" => $token,
"token2" => $token2,
"token3" => $token3,
"template" => $template,
"type" => $type
);
if(func_num_args()>5){
$arg_list = func_get_args();
if(isset($arg_list[6]))
$params["token10"]=$arg_list[6];
if(isset($arg_list[7]))
$params["token20"]=$arg_list[7];
}
return $this->execute($path, $params);
}
public function CallMakeTTS($receptor, $message, $date = null, $localid = null)
{
$path = $this->get_path("maketts", "call");
$params = array(
"receptor" => $receptor,
"message" => $message,
"date" => $date,
"localid" => $localid
);
return $this->execute($path, $params);
}
}
?>