irteel / php-smsgw
使用您的安卓手机作为irteel短信网关
v1.2.0
2023-10-14 04:01 UTC
Requires
- php: ^7.4|^8.1
Requires (Dev)
- phpunit/phpunit: ^9.0
This package is not auto-updated.
Last update: 2024-09-29 06:51:16 UTC
README
使用本应用程序,您可以轻松地将您的手机变成应用程序的短信网关。
您将获得管理面板和安卓应用程序。管理面板跟踪您使用此API发送的所有消息,安卓应用程序将您的手机变成短信网关。您发送的所有请求将首先存储在服务器上,使用位于https://smsgw.irteel.com的管理面板,然后将其交给安卓应用程序处理。安卓应用程序根据请求发送短信,并将消息的状态报告给管理面板。
功能
从使用任何编程语言开发的任何应用程序发送短信。使用包含前两列包含号码和消息的CSV或Excel文件发送批量消息。在管理面板中显示使用短信网关发送的消息状态。能够在管理面板中接收消息并使用WebHook进行响应。能够在发送批量消息时使用多个安卓设备登录,以在它们之间分割消息。能够创建其他用户,让他们可以使用手机使用短信网关。
安装
您可以通过composer安装此包
composer require irteel/php-smsgw
使用方法
PHP Integration 1. Setup config file or define all constants Include following code in your PHP file to start sending messages. define("SERVER", "https://smsgw.irteel.com"); ## Server URL define("API_KEY", "klmc81eb642f20f1ccc4ed03a32939582ff3bb058"); ## Enter the API_KEY from your developper panel define("USE_SPECIFIED", 0); define("USE_ALL_DEVICES", 1); define("USE_ALL_SIMS", 2); require 'vendor/autoload.php'; 2. Use Irteel\Smsgw namespace in your php file use Irteel\Smsgw\PhpSmsgw; class 3. Create PhpSmsgw instance $smsgw=new PhpSmsgw(SERVER,API_KEY); 4. Start using $smsgw instance ############################################################################################################################################ Send Single Message try { // Send a message using the primary device. $msg = $smsgw->sendSingleMessage("+11234567890", "This is a test of single message."); // Send a message using the Device ID 1. $msg = $smsgw->sendSingleMessage("+11234567890", "This is a test of single message.", 1); // Send a prioritize message using Device ID 1 for purpose of sending OTP, message reply etc… $msg = $smsgw->sendSingleMessage("+11234567890", "This is a test of single message.", 1, null, false, null, true); // Send a MMS message with image using the Device ID 1. $attachments = "https://example.com/images/footer-logo.png,https://example.com/downloads/sms-gateway/images/section/create-chat-bot.png"; $msg = $smsgw->sendSingleMessage("+11234567890", "This is a test of single message.", 1, null, true, $attachments); // Send a message using the SIM in slot 1 of Device ID 1 (Represented as "1|0"). // SIM slot is an index so the index of the first SIM is 0 and the index of the second SIM is 1. // In this example, 1 represents Device ID and 0 represents SIM slot index. $msg = $smsgw->sendSingleMessage("+11234567890", "This is a test of single message.", "1|0"); // Send scheduled message using the primary device. $msg = $smsgw->sendSingleMessage("+11234567890", "This is a test of schedule feature.", null, strtotime("+2 minutes")); print_r($msg); echo "Successfully sent a message."; } catch (Exception $e) { echo $e->getMessage(); } ############################################################################################################################################ Send Bulk Messages $messages = array(); for ($i = 1; $i <= 12; $i++) { array_push($messages, [ "number" => "+11234567890", "message" => "This is a test #{$i} of PHP version. Testing bulk message functionality." ]); } try { // Send messages using the primary device. $smsgw->sendMessages($messages); // Send messages using default SIM of all available devices. Messages will be split between all devices. $smsgw->sendMessages($messages, USE_ALL_DEVICES); // Send messages using all SIMs of all available devices. Messages will be split between all SIMs. $smsgw->sendMessages($messages, USE_ALL_SIMS); // Send messages using only specified devices. Messages will be split between devices or SIMs you specified. // If you send 12 messages using this code then 4 messages will be sent by Device ID 1, other 4 by SIM in slot 1 of // Device ID 2 (Represendted as "2|0") and remaining 4 by SIM in slot 2 of Device ID 2 (Represendted as "2|1"). sendMessages($messages, USE_SPECIFIED, [1, "2|0", "2|1"]); // Send messages on schedule using the primary device. $smsgw->sendMessages($messages, null, null, strtotime("+2 minutes")); // Send a message to contacts in contacts list with ID of 1. $smsgw->sendMessageToContactsList(1, "Test", USE_SPECIFIED, 1); // Send a message on schedule to contacts in contacts list with ID of 1. $smsgw->sendMessageToContactsList(1, "Test", null, null, strtotime("+2 minutes")); // Array of image links to attach to MMS message; $attachments = [ "https://example.com/images/footer-logo.png", "https://example.com/downloads/sms-gateway/images/section/create-chat-bot.png" ]; $attachments = implode(',', $attachments); $mmsMessages = []; for ($i = 1; $i <= 12; $i++) { array_push($mmsMessages, [ "number" => "+11234567890", "message" => "This is a test #{$i} of PHP version. Testing bulk MMS message functionality.", "type" => "mms", "attachments" => $attachments ]); } // Send MMS messages using all SIMs of all available devices. Messages will be split between all SIMs. $msgs = $smsgw->sendMessages($mmsMessages, USE_ALL_SIMS); print_r($msgs); echo "Successfully sent bulk messages."; } catch (Exception $e) { echo $e->getMessage(); } ############################################################################################################################################ Get remaining message credits try { $credits = $smsgw->getBalance(); echo "Message Credits Remaining: {$credits}"; } catch (Exception $e) { echo $e->getMessage(); } ############################################################################################################################################ Get messages and their current status try { // Get a message using the ID. $msg = $smsgw->getMessageByID(1); print_r($msg); // Get messages using the Group ID. $msgs = $smsgw->getMessagesByGroupID(')V5LxqyBMEbQrl9*J$5bb4c03e8a07b7.62193871'); print_r($msgs); // Get messages received in last 24 hours. $msgs = $smsgw->getMessagesByStatus("Received", null, null, time() - 86400); // Get messages received on SIM 1 of device ID 8 in last 24 hours. $msgs = $smsgw->getMessagesByStatus("Received", 8, 0, time() - 86400); print_r($msgs); } catch (Exception $e) { echo $e->getMessage(); } ############################################################################################################################################ Resend messages try { // Resend a message using the ID. $msg = $smsgw->resendMessageByID(1); print_r($msg); // Get messages using the Group ID and Status. $msgs = $smsgw->resendMessagesByGroupID('LV5LxqyBMEbQrl9*J$5bb4c03e8a07b7.62193871', 'Failed'); print_r($msgs); // Resend pending messages in last 24 hours. $msgs = $smsgw->resendMessagesByStatus("Pending", null, null, time() - 86400); // Resend pending messages sent using SIM 1 of device ID 8 in last 24 hours. $msgs = $smsgw->resendMessagesByStatus("Received", 8, 0, time() - 86400); print_r($msgs); } catch (Exception $e) { echo $e->getMessage(); } ############################################################################################################################################ Manage Contacts try { // Add a new contact to contacts list 1 or resubscribe the contact if it already exists. $contact = $smsgw->addContact(1, "+11234567890", "Test", true); print_r($contact); // Unsubscribe a contact using the mobile number. $contact = $smsgw->unsubscribeContact(1, "+11234567890"); print_r($contact); } catch (Exception $e) { echo $e->getMessage(); } ############################################################################################################################################ Send USSD request try { // Send a USSD request using default SIM of Device ID 1. $ussdRequest =$smsgw->sendUssdRequest("*150#", 1); print_r($ussdRequest); // Send a USSD request using SIM in slot 1 of Device ID 1. $ussdRequest = $smsgw->sendUssdRequest("*150#", 1, 0); print_r($ussdRequest); // Send a USSD request using SIM in slot 2 of Device ID 1. $ussdRequest = $smsgw->sendUssdRequest("*150#", 1, 1); print_r($ussdRequest); } catch (Exception $e) { echo $e->getMessage(); } ############################################################################################################################################ Get USSD requests try { // Get a USSD request using the ID. $ussdRequest = $smsgw->getUssdRequestByID(1); print_r($ussdRequest); // Get USSD requests with request text "*150#" sent in last 24 hours. $ussdRequests = $smsgw->getUssdRequests("*150#", null, null, time() - 86400); print_r($ussdRequests); } catch (Exception $e) { echo $e->getMessage(); } ############################################################################################################################################ Get Devices try { // Get all enabled devices for sending messages. $devices = $smsgw->getDevices() print_r($devices); } catch (Exception $e) { echo $e->getMessage(); }
测试
composer test
变更日志
请参阅变更日志以获取更多关于最近更改的信息。
贡献
请参阅贡献指南以获取详细信息。
安全
如果您发现任何与安全相关的问题,请通过电子邮件cyrille.bidongo@gmail.com而不是使用问题跟踪器来报告。
致谢
许可协议
MIT许可(MIT)。请参阅许可文件以获取更多信息。