onerecharge/onerecharge-php

Onerecharge 代理集成 PHP 库

dev-master 2016-10-19 01:34 UTC

This package is auto-updated.

Last update: 2024-09-06 06:04:02 UTC


README

  • 了解更多关于 Onerecharge 或成为 Onerecharge 代理的信息,请访问 www.onerecharge.com

功能

  • 获取授权令牌(从您的代理仪表板获取 API 访问密钥
  • 获取支持的账单支付
  • 发起即时充值/充值(话费)
  • 发起计划内的充值/充值(话费)
  • 取消计划内的账单支付
  • 在一处获取您的代理账户概要信息

示例

  • 发起即时充值/充值(话费)
    use Onerecharge\Agent;
    use Onerecharge\Util;
    use Onerecharge\BillPayment;

    //use the Util function like this to get array of supported telco names:
    echo Util::getSupportedBillType();
    //then get an Authorization token. you should store the retrieved token somewhere in your code.
    //tokens can be destroyed from your admin portal anytime (do not store your agent_id and password in your code.)
    $token = Agent::getToken($agent_id, $password);

    $agent = new Agent(API_ACCESS_KEY, $token);
    $billpayment = new BillPayment($agent);
    echo $billpayment->airtimeTopup("08025***373", "Etisalat", 100);

安装 onerecharge-php

安装 onerecharge-php 的推荐方法是使用 Composer

# Install Composer
curl -sS https://getcomposer.org/installer | php

接下来,运行 Composer 命令以安装最新稳定的 Guzzle 版本

php composer.phar require onerecharge/onerecharge-php

安装后,您需要要求 Composer 的自动加载器

require 'vendor/autoload.php';

然后您可以使用 composer 更新 onerecharge-php

composer.phar update