DAVXi/allmysms

用于访问AllMySMS API的PHP客户端库

1.0.2 2017-09-14 01:50 UTC

This package is auto-updated.

Last update: 2024-09-13 21:10:39 UTC


README

用于访问AllMySMS API的PHP客户端库。使用了官方文档:https://www.allmysms.com/_documents/api/http/AllMySMS_DocTechnique_Api_HTTP.pdf

Build Status Latest Stable Version Total Downloads Latest Unstable Version License composer.lock available Code Climate Test Coverage Issue Count

安装

此页面包含有关安装PHP库的信息。

需求

  • PHP版本5.3.0或更高版本(包括PHP 7)

获取客户端库

获取客户端库文件有两种选择。

使用Composer

您可以通过在composer.json中将它作为依赖项添加来安装库。

  "require": {
    "davaxi/allmysms": "^1.0"
  }

从GitHub克隆

库在GitHub上可用。您可以使用git clone命令将其克隆到本地存储库。

git clone https://github.com/davaxi/AllMySMS.git

文件处理

获取文件后,确保它们可供您的代码使用。如果您使用Composer,这会自动为您处理。如果不使用Composer,您需要在客户端库中添加autoload.php文件。

require '/path/to/allmysms/folder/autoload.php';

用法

初始化客户端

<?php

$client = new \Davaxi\AllMySMS\Client();
$client->setLogin('MyLogin');
$client->setApiKey('MyApiKey');
// Or
$client = new \Davaxi\AllMySMS\Client('MyLogin', 'MyApiKey');

发送短信

<?php

// ...

// SMS
$service = new Davaxi\AllMySMS\Service\Message\OutGoing($client);
$sms = new \Davaxi\ALlMySMS\Model\SMS();

// Required
$sms->addRecipient('0600000000');
$sms->setMessage('My message');

// Optional
$sms->setId('MyID');
$sms->setSender('MySociety');
$sms->setCampaign('MyCampaignName');
$sms->activeFlashMode(); 
$sms->activeEmailNotification();
$sms->setMasterAccountLogin('MasterLogin');
$sms->addRecipient('0600000000', ['PARAM_1' => 'David']);

$sms->setDate('+ 1 hour');
// or
$sms->setDate('2017-09-01 00:00:00');

// Send SMS (without optional configuration)
$response = $service->simpleSMS($sms);

// Send SMS (with optional configuration)
$response = $service->sendSMS($sms);

// If simulate 
$response = $service->simulateSMS($sms);

// To get SMS Length 
$smsLength = $sms->getLength();

// To get Message Length
$smsContentLength = $sms->getMessageLength();

发送彩信

<?php

// ...

// MMS
$service = new Davaxi\AllMySMS\Service\Message\OutGoing($client);
$mms = new \Davaxi\ALlMySMS\Model\MMS();
// Required
$sms->addRecipient('0600000000');
$mms->setMessage('MyMessage');
// or (and if message < 160 char)
$mms->setPictureUrl('http://.....');
// or 
$mms->setVideoUrl('http://.....');
// or 
$mms->setSoundUrl('http://.....');

// Optional
$sms->setId('MyID');
$mms->setCampaign('CampaignName');
$mms->setDate('+ 1 hour');
// or
$mms->setDate('2017-09-01 00:00:00');
$sms->activeEmailNotification();

// Send MMS
$response = $service->sendMMS($sms);

// To get MMS Length 
$smsLength = $sms->getLength();

// To get Message Length
$smsContentLength = $sms->getMessageLength();

发送电子邮件

<?php

// ...

// MMS
$service = new Davaxi\AllMySMS\Service\Message\OutGoing($client);
$email = new \Davaxi\ALlMySMS\Model\Email();

// Required
$email->setFrom('my@email.fr');
$email->setRecipient('email@test.fr');
$email->setSubject('My Subject');
$email->setContentHtml('My HTML content');

// Optional
$email->setFrom('my@email.fr', 'myAlias');
$email->setAlias('myAlias');
$email->setDate('+ 1 hour');
// or
$email->setDate('2017-09-01 00:00:00');
$email->setContentText('My Text content');
$email->setCampaignName('My Campaign Name');
$email->setReplyTo('replay@email.fr');

// Send Email
$service->sendEmail($email);