芒果/mango-php

Mango API PHP 客户端

0.1.2 2015-07-20 14:40 UTC

This package is not auto-updated.

Last update: 2024-09-28 16:15:29 UTC


README

这是一个PHP库,允许与 Mango API 交互

安装

依赖

* PHP 5.3+

使用Composer安装

如果你使用 Composer,将以下内容添加到你的 composer.json 中的 require

{
  "require" : {
    "mango/mango-php" : "dev-master"
  }
}

然后使用Composer的自动加载器加载它

require 'vendor/autoload.php';

从GitHub安装

要安装源代码

$ git clone git@github.com:mango/mango-php.git

在你的代码中包含 mango-php 并自动加载 requests

require_once '/path/to/mango-php/mango.php';
require_once '/path/to/rmccue/requests/Requests.php';
Requests::register_autoloader();

文档

文档可在 https://developers.getmango.com/en/api/?platform=php 找到

用法

设置你的密钥API

$mango = new Mango\Mango(array(
    "api_key" => "YOUR_SECRET_API_KEY"
));

创建客户

为了创建客户,你必须使用 所需的参数 调用 create() 方法。

$customer = $mango->Customers->create(array(
    "email" => "test-php@example.org",
    "name" => "Test Customer"
));
var_dump($customer);

获取单个客户

当你有一个客户的 uid 时,你可以使用 get() 方法获取完整详细信息

$customer = $mango->Customers->get("customer_1uqh884oy1ujh9y9eatm0jo3zxu0rm2s");
var_dump($customer);

你还可以使用与密钥API密钥验证的所有其他资源

测试

使用Composer安装模块及其开发依赖项

$ git clone git://github.com/mango/mango-php.git
$ cd mango-php
$ composer install

要运行测试,你需要Mango API密钥(模式沙箱)

export MANGO_SECRET_TEST_KEY='your secret test API key'
export MANGO_PUBLIC_TEST_KEY='your public test API Key'

运行测试

$ phpunit test

运行代码覆盖率

要运行代码覆盖率,你需要Xdebug

$ phpunit --coverage-html coverage

许可证

MIT许可证下授权。

版权(c)2014 Mango。