tatdev/dp_ms_client

DigiPeyk 消息服务客户端 SDK

1.0.1 2017-09-27 12:18 UTC

This package is not auto-updated.

Last update: 2024-09-18 22:26:01 UTC


README

digipeyk 消息服务的客户端包

使用 Composer 安装

curl -s http://getcomposer.org/installer | php
php composer.phar require tatdev/dp-ms-client

使用方法

使用此包,您可以与 digipeyk 消息服务的以下方法一起工作:

  • sendMessage − 向多个接收者发送相同内容的短信
  • sendMessageMultiple − 向多个接收者发送具有多个内容的短信
  • sendEmail − 向多个接收者发送相同内容的电子邮件
  • sendEmailMultiple − 向多个接收者发送具有多个内容的电子邮件

示例

sendMessage

use \Tatdev\DPMSClient\Clients\Client;
use \Tatdev\DPMSClient\HttpClients\CurlHttpClient;
use \Tatdev\DPMSClient\SendObjects\Value;

$client = new Client(new CurlHttpClient(), 'http://stg.digipeyk.com:8030/api/v1');

$order = $client->sendSms(
    1, // sender id
    ['09109934767'], // array of receptors
    null, // body of message (pass `null` if you use template)
    1, // template id (pass `null` if you use body) 
    [new Value('name','ali')], // array of Value object (pass `[]` if template haven`t variables or using body)
    60, // accept latency to send and check status
    3, // retry count for send
    15, // wait time between every try for check status
    5, // retry count for check status if pending
    'Y/m/d H:i', // jalali date format for schedule sending
    '1396/07/05 16:00', // jalali date for send this message at that time
    false // `true` return order in array format | `false' (default) return order in object format
);

sendMessageMultiple

use \Tatdev\DPMSClient\Clients\Client;
use \Tatdev\DPMSClient\HttpClients\CurlHttpClient;
use \Tatdev\DPMSClient\SendObjects\Value;
use \Tatdev\DPMSClient\SendObjects\SingleMessage;

$client = new Client(new CurlHttpClient(), 'http://stg.digipeyk.com:8030/api/v1');

$order = $client->sendSmsMultiple(
    1, // sender id
    [ // array of SingleMessage object
        new SingleMessage(
            '09109934767', // receptor
            null, // body of message (pass `null` if you use template)
            1, // template id (pass `null` if you use body) 
            [new Value('name', 'ali')] // array of Value object (pass `[]` if template haven`t variables or using body)
        )
    ],
    60, // accept latency to send and check status
    3, // retry count for send
    15, // wait time between every try for check status
    5, // retry count for check status if pending
    'Y/m/d H:i', // jalali date format for schedule sending
    '1396/07/05 16:00', // jalali date for send this message at that time
    false // `true` return order in array format | `false' (default) return order in object format
);

sendEmail

use \Tatdev\DPMSClient\Clients\Client;
use \Tatdev\DPMSClient\HttpClients\CurlHttpClient;
use \Tatdev\DPMSClient\SendObjects\Value;

$client = new Client(new CurlHttpClient(), 'http://stg.digipeyk.com:8030/api/v1');

$order = $client->sendEmail(
    1, // sender id
    ['moradi-ali@outlook.com'], // array of receptors
    'subject', // subject of email
    null, // body of email (pass `null` if you use template)
    1, // template id (pass `null` if you use body) 
    [new Value('name','ali')], // array of Value object (pass `[]` if template haven`t variables or using body)
    ["john@domain.com"], // array of cc
    ["blabla@domain.com"], // array of bcc
    60, // accept latency to send and check status
    3, // retry count for send
    15, // wait time between every try for check status
    5, // retry count for check status if pending
    'Y/m/d H:i', // jalali date format for schedule sending
    '1396/07/05 16:00', // jalali date for send this email at that time
    false // `true` return order in array format | `false' (default) return order in object format
);

sendEmailMultiple

use \Tatdev\DPMSClient\Clients\Client;
use \Tatdev\DPMSClient\HttpClients\CurlHttpClient;
use \Tatdev\DPMSClient\SendObjects\Value;
use \Tatdev\DPMSClient\SendObjects\SingleEmail;

$client = new Client(new CurlHttpClient(), 'http://stg.digipeyk.com:8030/api/v1');

$order = $client->sendEmailMultiple(
    1, // sender id
    [ // array of SingleEmail object
        new SingleEmail(
            'moradi-ali@outlook.com', //receptor
            'subject', // subject of email
            null, // body of email (pass `null` if you use template)
            1, // template id (pass `null` if you use body) 
            [new Value('name', 'ali')], // array of Value object (pass `[]` if template haven`t variables or using body)
            ["john@domain.com"], // array of cc
            ["blabla@domain.com"] // array of bcc
        )
    ],
    60, // accept latency to send and check status
    3, // retry count for send
    15, // wait time between every try for check status
    5, // retry count for check status if pending
    'Y/m/d H:i', // jalali date format for schedule sending
    '1396/07/05 16:00', // jalali date for send this email at that time
    false // `true` return order in array format | `false' (default) return order in object format
);