tahaghafuri / melipayamak
melipayamak网络服务的PHP包装器
3.0.0
2023-09-14 10:49 UTC
Requires
- php: >=5.4.0
This package is auto-updated.
Last update: 2024-09-14 13:02:30 UTC
README
安装
composer require tahaghafuri/melipayamak
或者通过在composer.json文件中添加以下行
"tahaghafuri/melipayamak": "*"
然后执行命令
composer update
用法
发送短信的示例代码
require __DIR__ . '/vendor/autoload.php'; use Melipayamak\MelipayamakApi; try{ $username = 'username'; $password = 'password'; $api = new MelipayamakApi($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(); }
由于国家短信服务不仅限于发送短信,您可以通过以下方式完全访问网络服务
// وب سرویس پیامک $smsRest = $api->sms(); $smsSoap = $api->sms('soap'); // وب سرویس تیکت پشتیبانی $ticket = $api->ticket(); // وب سرویس برای مدیریت کامل ارسال انبوه پیامک $branch = $api->branch(); //وب سرویس کاربران $users = $api->users(); //وب سرویس دفترچه تلفن $contacts = $api->contacts()
异步状态
您还可以在异步模式下使用国家短信服务。以下是如何在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短信网络服务的差异
由于国家短信服务为开发者提供了全面的服务,为了方便开发者使用短信服务,除了主要的soap服务外,还提供rest服务,以便开发者更容易使用。这两种服务的主要区别在于可用的方法数量。对于基本工作,可以使用rest服务;对于更多和更高级的使用,应使用soap服务。有关更多关于服务的信息,请访问您的服务面板。
更多信息
有关更多信息、获取网络服务指南以及了解输入和输出参数,请访问国家短信服务介绍页面。
短信服务
网络服务方法
发送
$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服务中,除了发送数组形式的号码外,还可以发送单个号码数组。
接收发送状态
$smsRest->isDelivered($recId); $smsSoap->isDelivered($recId);
- 在soap服务中,可以发送数组而不是单个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);
短信音频服务
发送带音频的短信
$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);
大量/区域发送服务
接收银行分支标识符
$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);
票务服务
记录新票务
$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);
电话簿服务
添加新组
$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);
用户服务网关
登记付款凭证
$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();