chaboksms api 的 PHP 封装

dev-main 2021-10-20 11:45 UTC

This package is auto-updated.

Last update: 2024-09-20 17:58:08 UTC


README

介绍 Chabok SMS Web 服务

Chabok SMS 是一个完整的 Web 服务,用于发送和接收短信和语音短信,以及全面管理其他服务,您可以轻松使用。

安装

在安装之前,您需要在 Chabok SMS 网站上注册。

注册后,您将获得 200 条免费短信以测试 Web 服务。

注册后,您可以通过以下方式安装:

composer require chaboksms/php:1.0.5

或者通过将以下行添加到 composer.json 文件中

"chaboksms/php": "1.0.5"

然后执行以下命令

composer update

使用方法

发送短信示例代码

require __DIR__ . '/vendor/autoload.php';
use Chaboksms\ChaboksmsApi;
try{
    $username = 'username';
    $password = 'password';
    $api = new ChaboksmsApi($username,$password);
    $sms = $api->sms();
    $to = '09123456789';
    $from = '5000...';
    $text = 'تست وب سرویس چابک اس ام اس';
    $response = $sms->send($to,$from,$text);
    $json = json_decode($response);
    echo $json->Value; //RecId or Error Number 
}catch(Exception $e){
    echo $e->getMessage();
}

由于 Chabok SMS Web 服务不仅限于发送短信,您可以通过以下方式完全访问 Web 服务

// وب سرویس پیامک
$smsRest = $api->sms();
$smsSoap = $api->sms('soap');
// وب سرویس تیکت پشتیبانی
$ticket = $api->ticket();
// وب سرویس برای مدیریت کامل  ارسال انبوه پیامک
$branch = $api->branch();
//وب سرویس کاربران
$users = $api->users();
//وب سرویس دفترچه تلفن
$contacts = $api->contacts()
异步模式

您还可以在异步模式下使用 Chabok SMS Web 服务。以下是在 PHP 中准备异步方法的示例。请注意,异步命令将在调用 execute 方法(并行)时执行。

// وب سرویس پیامک
$smsRestAsync = $api->sms('async');
$smsSoapAsync = $api->sms('soap', 'async');
// وب سرویس تیکت پشتیبانی
$ticket = $api->ticket('async');
// وب سرویس برای مدیریت کامل  ارسال انبوه پیامک
$branch = $api->branch('async');
//وب سرویس کاربران
$users = $api->users('async');
//وب سرویس دفترچه تلفن
$contacts = $api->contacts('async');

REST 和 SOAP Web 服务的区别

由于 Chabok SMS 为开发者提供了完整的 Web 服务,为了方便与短信 Web 服务工作,除了主要的 SOAP Web 服务外,还为开发者提供了 REST Web 服务,以便他们更容易使用。这两个服务的主要区别在于您可以与之工作的方法数量。对于基本工作,您可以使用 REST Web 服务;对于更高级的使用,您需要使用 SOAP Web 服务。有关更多信息和 Web 服务的详细信息,请参阅您的 Web 服务面板。

更多信息

有关更多信息和 Web 服务的详细说明以及熟悉输入和输出参数,请访问Chabok SMS Web 服务介绍页面。

短信 Web 服务

Web 服务方法

发送

$smsRest->send($to,$from,$text,$isFlash);
$smsSoap->send($to,$from,$text,$isFlash);

添加黑名单

$smsSoap->addblacklist($title);

添加模式或模板

$smsSoap->sharedServiceBodyAdd($title,$body,$blackListId);

查看已添加的模式

$smsSoap->getSharedServiceBody();

通过模式(共享服务行)发送

$smsRest->sendByBaseNumber($text,$to,$bodyId);
$smsSoap->sendByBaseNumber($text,$to,$bodyId);
  • 在 SOAP Web 服务中,发送时可以使用数字数组,也可以使用单个数字。

获取发送状态

$smsRest->isDelivered($recId);
$smsSoap->isDelivered($recId);
  • 在 SOAP Web 服务中,发送时可以使用数组而不是单个 ID。

短信列表

$smsRest->getMessages($location,$index,$count,$from);
$smsSoap->getMessages($location,$index,$count,$from);
$smsSoap->getMessagesStr($location,$index,$count,$from);
// جهت دریافت به صورت رشته ای
$smsSoap->getMessagesByDate($location,$index,$count,$from,$dateFrom,$dateTo);
//جهت دریافت بر اساس تاریخ
$smsSoap->getUsersMessagesByDate($location,$index,$count,$from,$dateFrom,$dateTo);
// جهت دریافت پیام های کاربران بر اساس تاریخ 

库存

$smsRest->getCredit();
$smsSoap->getCredit();

基本费率/发送前获取价格

$smsRest->getBasePrice();
$smsSoap->getPrice($irancellCount,$mtnCount,$from,$text);

专属号码列表

$smsRest->getNumbers();

检查收到的短信数量

$smsSoap->getInboxCount($isRead);
//پیش فرض خوانده نشده 

发送高级短信

$smsSoap->send2($to,$from,$text,$isflash,$udh);

查看短信详情

$smsSoap->getMessagesReceptions($msgId,$fromRows);

删除收到的短信

$smsSoap->remove($msgIds);

定时发送

$smsSoap->sendSchedule($to,$from,$text,$isflash,$scheduleDateTime,$period);

同步定时发送

$smsSoap->sendMultipleSchedule($to,$from,$text,$isflash,$scheduleDateTime,$period);

发送到期

$smsSoap->addUsance($to,$from,$text,$isflash,$scheduleStartDateTime,$repeatAfterDays,$scheduleEndDateTime);

查看定时发送状态

$smsSoap->getScheduleStatus($schId);

删除定时短信

$smsSoap->removeSchedule($schId);

语音短信 Web 服务

发送带语音的短信

$smsSoap->sendWithSpeech($to,$from,$text,$speech);

定时发送带语音的短信

$smsSoap->sendWithSpeechSchduleDate($to,$from,$text,$speech,$scheduleDate);

获取带语音的短信状态

$smsSoap->getSendWithSpeech($recId);

定时群呼

$smsSoap->SendBulkSpeechText($title, $body, $receivers, $DateToSend, $repeatCount);

带文件选择的定时群呼

$smsSoap->SendBulkVoiceSMS($title, $voiceFileId, $receivers, $DateToSend, $repeatCount);

上传音频文件

$smsSoap->UploadVoiceFile($title, $base64StringFile);

批量/区域发送 Web 服务

获取分支号码的 ID

$branch->get($owner);

添加新的号码库

$branch->add($branchName,$owner);

向号码库添加号码

$branch->addNumber($mobileNumbers,$branchId);

删除号码库

$branch->remove($branchId);

通过号码库发送批量

$branch->sendBulk($from,$title,$message,$branch,$DateToSend,$requestCount,$bulkType,$rowFrom,$rangeFrom,$rangeTo);
$branch->sendBulk2($from,$title,$message,$branch,$DateToSend,$requestCount,$bulkType,$rowFrom,$rangeFrom,$rangeTo);

现有号码数量

$branch->getBulkCount($branch,$rangeFrom,$rangeTo);

批量发送报告

$branch->getBulkReceptions($bulkId,$fromRows);

设置发送状态

$branch->getBulkStatus($bulkId);

今天的发送次数

$branch->getTodaySent();

总发送次数

$branch->getTotalSent();

删除区域发送

$branch->removeBulk($id);

同步发送

$branch->sendMultipleSms($to,$from,$text,$isflash,$udh);

报告状态显示器

$branch->updateBulkDelivery($bulkId);

票务 Web 服务

注册新工单

$ticket->add($title,$content,$aletWithSms);

搜索和获取工单

$ticket->getReceived($ticketOwner,$ticketType,$keyword);

获取用户工单数量

$ticket->getReceivedCount($ticketType);

获取已提交工单

$ticket->getSent($ticketOwner,$ticketType,$keyword);

获取已提交工单数量

$ticket->getSentCount($ticketType);

回复工单

$ticket->response($ticketId,$type,$content,$alertWithSms);

电话簿Web服务

添加新组

$contacts->addGroup($groupName,$Descriptions,$showToChilds);

添加新用户

$contacts->add($options);

检查电话簿中号码是否存在

$contacts->checkMobileExist($mobileNumber);

获取电话簿信息

$contacts->get($groupId,$keyword,$from,$count);

获取组信息

$contacts->getGroups();

编辑联系人

$contacts->change($options);

删除联系人

$contacts->remove($mobilenumber);

获取个人事件信息

$contacts->getEvents($contactId);

用户Web服务

注册支付收据

$users->addPayment($options);

在系统中添加新用户

$users->add($options);

在系统中添加新用户(完整)

$users->addComplete($options);

在系统中添加新用户(带位置)

$users->addWithLocation($options);

获取用户ID

$users->authenticate();

更改有效期

$users->changeCredit($amount,$description,$targetUsername,$GetTax);

忘记密码

$users->forgotPassword($mobileNumber,$emailAddress,$targetUsername);

获取用户基本费用

$users->getBasePrice($targetUsername);

获取用户有效期

$users->getCredit($targetUsername);

获取用户信息

$users->getDetails($targetUsername);

获取用户电话号码

$users->getNumbers();

获取用户交易

$users->getTransactions($targetUsername,$creditType,$dateFrom,$dateTo,$keyword);

获取用户信息

$users->get();

获取过滤信息

$users->hasFilter($text);

删除用户

$users->remove($targetUsername);

查看省份

$users->getProvinces();

查看县级代码

$users->getCities($provinceId);

查看用户有效期

$users->getExpireDate();