wekreit/orange-sms

PHP 库,用于访问 Orange SMS API 发送短信

dev-main 2023-12-26 11:26 UTC

This package is auto-updated.

Last update: 2024-09-26 13:04:30 UTC


README

使用 PHP 通过 Orange SMS API 发送短信

如何使用

首先创建一个新的客户端实例,通过提供来自您的 Orange API SMS 订阅的 clientIdclientSecret,然后您就可以使用它了

<?php
use Wekreit\Http\SMSClient;
use Wekreit\SMS;

$client = SMSClient::initInstance("clientId", "clientSecret");

$sms = new SMS($client);
$sms->from("2250000") // senderAddress
    ->to("2250709000000") // Recipient phone number
    ->message("Test orange api sms") // text message
    ->send();

或者如果您已经有了一个 token

$client = SMSClient::initInstance("token");

$sms = new SMS($client);
$sms->from("2250000") // senderAddress
    ->to("2250709000000") // Recipient phone number
    ->message("Test orange api sms") // text message
    ->send();

获取 token 的方法

$client = SMSClient::initInstance("clientId", "clientSecret");
$client->getToken(); // return token