定制 mocean/client 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mocean/client

最新稳定版本:2.2.0

Composer 安装命令:

composer require mocean/client

包简介

PHP Client for using Mocean's API.

README 文档

README

Latest Stable Version Build Status codecov codacy StyleCI License Total Downloads

This library requires a minimum PHP version of 5.5

This is the PHP client library for use Mocean's API. To use this, you'll need a Mocean account. Sign up for free at moceanapi.com.

Installation

To use the client library you'll need to have created a Mocean account.

To install the PHP client library using Composer.

composer require mocean/client

Usage

If you're using composer, make sure the autoloader is included in your project's bootstrap file:

require_once "vendor/autoload.php";

For version >=2.2.0

There are 2 ways to connect to MoceanAPI
Option 1: Create a client with your API token

use Mocean\Client;
use Mocean\Client\Credentials\Basic;

$mocean = new Client(new Basic(['apiToken' => 'API_TOKEN_HERE']));

Option 2 (legacy): Create a client with your API key and secret

use Mocean\Client;
use Mocean\Client\Credentials\Basic;

$mocean = new Client(new Basic(['apiKey' => 'API_KEY_HERE', 'apiSecret' => 'API_SECRET_HERE']));

For version <2.2.0

Create a client with your API key and secret:

use Mocean\Client;
use Mocean\Client\Credentials\Basic;

$mocean = new Client(new Basic('API_KEY_HERE', 'API_SECRET_HERE'));

Example

To use Mocean's SMS API to send an SMS message, call the $mocean->message()->send(); method.

The API can be called directly, using a simple array of parameters, the keys match the parameters of the API.

$res = $mocean->message()->send([
    'mocean-to' => '60123456789',
    'mocean-from' => 'MOCEAN',
    'mocean-text' => 'Hello World'
]);

echo $res;

Responses

For your convenient, the API response data can be accessed either using php object style or array style

echo $res;            //show full response string
echo $res['status'];  //show response status, '0' in this case
echo $res->status;    //same as above

Documentation

Kindly visit MoceanApi Docs for more usage

License

This library is released under the MIT License

统计信息

  • 总下载量: 6.92k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 1
  • 依赖项目数: 2
  • 推荐数: 1

GitHub 信息

  • Stars: 7
  • Watchers: 1
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-06-27