hpsweb/laravel-whatsapi

一个易于使用的PHP类,用于访问我的服务器的WhatsApp API

1.3.4 2022-12-21 03:30 UTC

This package is auto-updated.

Last update: 2024-09-21 07:09:41 UTC


README

Build Status Latest Stable Version

使用touchSMS发送短信的官方助手库

安装

composer require touchsms/touchsms

用法

require_once('vendor/autoload.php');

use Hpsweb\WhatsAPI;

$touchSms = new WhatsAPI('YOUR_API_ID', 'YOUR_API_PASSWORD');

// access token & token id can be generated at https://platform.touchsms.com.au/apis/

发送短信

$response = $touchSms->sendMessage('hello world', '61491570156');

print_r($response);

输出

stdClass Object
(
    [code] => 200
    [errors] => 0
    [message] =>
)

查看用户详情

$response = $touchSms->checkBalance();

print_r($response);

输出

stdClass Object
(
    [username] => john.doe@sandbox
    [credits] => 5000
    [senderid] => sandboxAPI
    [mobile] => 61491570156
    [code] => 200
)

示例

示例可以在examples目录中找到。

php examples/sendsms.php
php examples/users.php

测试

测试通过沙箱URL和沙箱凭据运行。

您可以使用自己的凭据更新测试,并在touchSMS构造函数上移除最后的true参数。

phpunit