smslink / smsgateway
SMSLink.ro是一家领先的短信服务提供商,每年发送超过1.75亿条短信。可以向罗马尼亚所有移动网络以及全球168个国家和1000多个移动运营商发送短信。
v1.2
2021-05-26 17:52 UTC
This package is auto-updated.
Last update: 2024-09-13 23:21:45 UTC
README
这是使用SMSLink.ro API发送短信的集成示例,称为短信网关。SMSLink.ro允许您向罗马尼亚的所有移动网络以及全球168个国家和1000多个移动运营商发送短信。
安装
使用Composer(PHP的依赖管理器)
$ composer require smslink/smsgateway
smslink/smsgateway包在Packagist - PHP包仓库
要求
- 在SMSLink.ro上创建账户
- 在SMSLink.ro / SMS Gateway / 配置 & 设置处创建一个短信网关连接。每个短信网关连接是一对连接ID和密码。
支持的功能
- $Connection->sendMessage() - 发送短信
- $Connection->accountBalance() - 获取SMSLink账户余额
特性
- 支持HTTP和HTTPS协议
- 支持PHP cURL GET、PHP cURL POST和file_get_contents()
系统要求
- PHP 5或更高版本,具有PHP cURL库或file_get_contents,需要在php.ini中设置allow_url_fopen为1
- Composer - PHP的依赖管理器
- smslink/smsgateway包在Packagist - PHP包仓库
使用Composer的示例
<?php /* * * Require Autoload (change autoload.php path to match your project) * */ require_once 'vendor/autoload.php'; /* * * Include the SMSLink\SMSGateway\Connection namespace * */ use SMSLink\SMSGateway\Connection; /* * * * Initialize SMS Gateway * * Get your SMSLink / SMS Gateway Connection ID and Password from * https://www.smslink.ro/get-api-key/ * * * */ $Connection = new Connection(); $Connection->setConnectionCredentials("MyConnectionID", "MyConnectionPassword"); /* * Sets the method in which the parameters are sent to SMS Gateway * * 1 for cURL GET (make sure you have PHP cURL installed) (default and recommended) * 2 for cURL POST (make sure you have PHP cURL installed) * 3 for file_get_contents (requires allow_url_fopen to be set to 1 in php.ini) * (recommended if you do not have PHP cURL installed) */ $Connection->setRequestMethod(1); /* * Sets the protocol that will be used by SMS Gateway (HTTPS or HTTP). */ $Connection->setProtocol("HTTPS"); /* * Display account balance before sending SMS */ $accountBalance = $Connection->accountBalance(); echo "My Account Balance is: ".$accountBalance["national-SMS"]." national SMS, ". $accountBalance["international-SMS"]." national SMS<br />"; /* * Sends SMS #1 */ $messageId = $Connection->sendMessage("07xyzzzzzz", "My first hello world message."); if ($messageId == false) echo "Message sent failed. Log: ".$Connection->getLastLogMessage().".<br />"; else echo "Message successfully sent with ID: ".$messageId.".<br />"; /* * Sends SMS #2 */ $messageId = $Connection->sendMessage("07xyzzzzzz", "My second hello world message."); if ($messageId == false) echo "Message sent failed. Log: ".$Connection->getLastLogMessage().".<br />"; else echo "Message successfully sent with ID: ".$messageId.".<br />"; /* * Display account balance after sending SMS */ $accountBalance = $Connection->accountBalance(); echo "My Account Balance is: ".$accountBalance["national-SMS"]." national SMS, ". $accountBalance["international-SMS"]." national SMS<br />"; /* * Display the communication log with SMSLink */ $Connection->displayLogMessages(); ?>
不使用Composer的示例
SMSLink.ro 短信网关也可以在不使用Composer的情况下使用。对于不使用Composer使用SMSLink短信网关,请参阅以下示例。
文档
SMSLink - SMS网关API的完整文档可以在此处找到,描述了所有可用的API(HTTP GET / POST、SOAP / WSDL、JSON等)。
附加模块和集成
SMSLink还提供针对主要电子商务平台(本地和云)的模块,使用Microsoft Power Automate、Zapier或Integromat进行集成,以及许多其他有用功能。了解更多关于所有可用功能的信息请在此处。
支持
对于技术支持查询,请联系我们contact@smslink.ro或使用此处描述的任何其他可用方法。