markvesterskov / inmobile-php-api
此包已被废弃,不再维护。作者建议使用markvesterskov/inmobile-php-client包代替。
此包最新版本(v2.0.3.4)没有提供许可证信息。
InMobile PHP Api 的 Composer 端口
v2.0.3.4
2018-02-28 15:15 UTC
Requires
- php: 5.4.0 || ^7.0
This package is not auto-updated.
Last update: 2021-08-24 07:50:35 UTC
README
这是一个简单的 Inmobile PHP API 包装器,可以通过 Composer 安装,而不是手动安装。
代码示例
API 与您 InMobile 账户开发者页面上的常规 API 相同。
安装
composer require MarkVesterskov\inmobile-php-api
使用
use MarkVesterskov\InmobilePHPApi\MM_Connector;
use MarkVesterskov\InmobilePHPApi\MM_Message;
$apiKey = 'INSERT APIKEY';// Found at the top of the documentation page
// Instantiate an API client object
$MM_Connector = new MM_Connector(
$apiKey,
'https://mm.inmobile.dk', // Server root address
'http://mywebsite.com/example/messagestatus' // Optional for status callbacks
);
/*
Prepare some messages to be sent. You can repeat this step multiple times
to send multiple messages in a single http call
*/
$msg = new MM_Message(
'Hello world', // Message text
array('4512345678'), // Msisdn (phonenumber with countrycode) for the receiver
'1245'); // The sendername. This could be a phonenumber or your company name
// Optionally a send time can be specified
// $msg->setSendTime('2020-01-20 18:30:00');
$MM_Connector->addMessage($msg);
/* Send the payload */
$success = $MM_Connector->send();
if($success)
{
/* Read the message ids */
$messageIds = $MM_Connector->getMessageIds();
/*
$messageIds contains an array with message id's and its corresponding msisdn
Example:
Array
(
[0] => Array
(
[msisdn] => 4512345678
[id] => fd0ab916-e960-49d0-bb2e-361771818393
)
)
*/
print_r($messageIds);
echo 'Success!';
}
else
{
/*
This function returns the remote error code
*/
print_r($MM_Connector->getError());
echo 'Error!';
}