desoft/entumovil

dev-main 2021-11-26 20:53 UTC

This package is auto-updated.

Last update: 2024-09-20 19:35:16 UTC


README

安装

composer require desoft/entumovil --with-all-dependencies

使用

发布资源

在终端运行并选择相应的包选项

php artisan vendor:publish

之后,会在config/路径下发布一个配置文件

在控制器中注入一个ConexionEnTuMovil实例

public function example_controller(ConexionEnTuMovil $conexionEnTuMovil)
{
    // Código
}

在ConexionEnTuMovil对象中存在3个方法

receive
$conexionEnTuMovil->receive(Array $payload): String // devuelve el texto (sin la clave si **hasKeyword** está en true)

$payload = [
    'hash' => $hash,
    'smsc_id' => $smscId,
    'id' => $id,
    'msisdn' => $msisdn,
    'mstext' => $mstext,
];

此方法负责验证通过api发送的hash是否与从payload字段创建的hash相匹配。依赖于配置文件enTuMovil中的hasKeyword值。如果hasKeyword为true,则等待消息中存在该键并只返回消息的有用文本。如果为false,则返回全部文本

send
$conexionEnTuMovil->send(String $message, String $recipient, String $urlCallback = null): Json // Retorna respuesta de la api

向配置文件中定义的路径发送post请求,其中包含要发送的message,接收者(可以是消息id或电话号码)以及是否期望通过字段urlCallback收到确认响应

callback
$conexionEnTuMovil->callback(Array $payload): String // devuelve el estado

$payload = [
    'cliMsgId' => $cliMsgId,
    'smscId' => $smscId,
    'hash' => $hash,
    'status' => $status,
];