vhtvn/vht-rest-client
Composer 安装命令:
composer require vhtvn/vht-rest-client
包简介
Example library for the vht web services
关键字:
README 文档
README
Example code for the VHT RESTful API
Introduction
Features
This library's features include the following.
Installation
This library is available on Packagist. The recommended way to install this library is through Composer:
$ php composer.phar require vhtvn/vht-rest-client dev-master
Usage
Before testing code below, we must require php file "autoload.php"
require(BASE_DIR . 'vendor/autoload.php');
Airtime
$apiKey = ''; // your apikey
$apiSecretKey = ''; // your apisecret
$mac = \Vht\Common\VhtHelper::buildMacForAuthentication(array($apiKey, $apiSecretKey));
$airtime = new \Vht\Airtime($apiKey, $mac);
$balance = $airtime->get('getbalances');
if ($airtime->getLastResponse()['headers']['http_code'] === 200) {
echo "Success\n";
print_r($balance);
} else {
echo "Fail\n";
print_r($airtime->getLastRequest());
print_r($airtime->getLastResponse());
print_r($balance);
}
--
$params = array(
'action' => $action,
'apikey' => $apiKey,
'servicecode' => $serviceCode,
'account' => $account,
'amount' => $amount,
'trace' => $trace,
'timestamp' => $timeStamp,
);
$mac = \Vht\Common\VhtHelper::buildMacForAuthentication(array($action, $apiKey, $serviceCode, $account, $amount, $trace, $timeStamp, $apiSecretKey));
$airtime = new \Vht\Airtime($apiKey, $mac);
$topup = $airtime->get('topups', $params);
if ($airtime->getLastResponse()['headers']['http_code'] === 200) {
echo "Success\n";
print_r($topup);
} else {
echo "Fail\n";
print_r($airtime->getLastRequest());
print_r($airtime->getLastResponse());
print_r($topup);
}
ZMS
$apiKey = ''; // your apikey
$apiSecretKey = ''; // your apisecret
$zmsObj = new \Vht\Zms($apiKey, $apiSecretKey);
$params = array(
'phone' => '',
'message' => 'The content of the message',
'sms' => 'Content of SMS message',
'is_notify' => true,
);
$result = $zmsObj->post('zalophones/text', $params);
if ($zmsObj->getLastResponse()['headers']['http_code'] === 201) {
echo "Success\n";
} else {
echo "Fail\n";
print_r($zmsObj->getLastRequest());
print_r($zmsObj->getLastResponse());
print_r($result);
}
SMS
$apiKey = ''; // your apikey
$apiSecret = ''; // your apisecret
$brandName = new \Vht\SmsBrandName($apiKey);
//$brandName->verifySsl = false;
$params['submission'] = array(
'api_key' => $apiKey,
'api_secret' => $apiSecret,
'sms' => array(
array(
'id' => (string) \Ramsey\Uuid\Uuid::uuid4(),
'brandname' => 'VHT',
'text' => 'Form VHT with love',
'to' => '' //your phone 0xxx
)
)
);
$result = $brandName->post('ccsms', ($params));
if ($brandName->getLastResponse()['headers']['http_code'] === 200) {
echo "Success\n";
} else {
echo "Fail\n";
print_r($brandName->getLastRequest());
print_r($brandName->getLastResponse());
print_r($brandName->getLastError());
print_r($result);
}
统计信息
- 总下载量: 400
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-06-20