dartui/multiinfo

此包已被废弃,不再维护。作者建议使用 nextgen-tech/multiinfo 包。

Polkomtel MultiInfo 集成,用于从 Laravel 应用程序发送短信

1.3.1 2019-09-05 07:28 UTC

This package is auto-updated.

Last update: 2021-08-25 10:34:11 UTC


README

此包已被废弃,不应使用。请使用 https://github.com/nextgen-tech/multiinfo-php 代替。

Laravel MultiInfo

Polkomtel MultiInfo 集成,用于从 Laravel 应用程序发送短信

安装

需要包

composer require dartui/multiinfo

服务提供者

'providers' => [
    ...
    Dartui\Multiinfo\ServiceProvider::class,
];

发布配置

php artisan vendor:publish --provider=Dartui\\Multiinfo\\ServiceProvider

配置包

'url'        => 'https://api1.multiinfo.plus.pl', // API base URL

'login'      => null, // API user login
'password'   => null, // API user password
'service_id' => null, // API user service id

'cert'       => [
    'is_nss'   => false, // Whether cURL is using NSS or no
    'nicename' => null,  // Nicename of certificate (required for NSS)
    'path'     => null,  // Certificate absolute path on server or path to NSS DB
    'password' => null,  // Certificate password
    'type'     => 'P12', // Certificate type (PEM or P12)
],

使用(请求和响应)

每个响应都继承这些方法

$response->getCode();        // status code
$response->getDescription(); // response in text format

$response->hasError();
$response->getError();

向单个电话号码发送短信

请求

$multiinfo = app('multiinfo');

$sendSms = $multiinfo->request('sendSms')
    ->setDestination('48123456789') // required
    ->setMessage('Hello world!')    // required
    ->setOrigin('New Origin')       // optional
    ->send();

响应

$sendSms->getMessageId(); // sent SMS id

获取发送到 MultiInfo 的最旧短信

请求

$multiinfo = app('multiinfo');

$getSms = $multiinfo->request('getSms')
    ->setManualConfirmation(true) // optional, default false
    ->setDeleteContent(true)      // optional, default false
    ->setTimeout(5000)            // optional
    ->send();

响应

$getSms->getMessageId();   // received SMS id
$getSms->getSender();      // sender phone number
$getSms->getReceiver();    // receiver phone number
$getSms->getMessageType(); // message type id
$getSms->getMessage();     // message content
$getSms->getProtocol();    // protocol id
$getSms->getEncoding();    // encoding id
$getSms->getServiceId();   // service id
$getSms->getConnector();   // connector id
$getSms->getReceiveDate(); // received date

确认接收短信

请求

$multiinfo = app('multiinfo');

$confirmSms = $multiinfo->request('confirmSms')
    ->setMessageId(123456)   // required
    ->setDeleteContent(true) // optional, default false
    ->send();

响应

此响应没有其他额外方法。

向多个电话号码发送不同信息的短信

请求

$multiinfo = app('multiinfo');

$package = $multiinfo->request('package')
    ->setMessage('Hello world!')  // default message
    ->setOrigin('New Origin')     // optional
    ->addDestination('123456789')
    ->addDestination('234567890') // to this numbers will be send default message
    ->addDestination('987654321', 'Hello another world!') // personalized message
    ->send();

响应

$package->getPackageId(); // sent package id