tobexkee / reloadly

一个简单的PHP库,用于与reloadly API交互

dev-master 2021-05-26 14:16 UTC

This package is auto-updated.

Last update: 2024-09-26 22:37:13 UTC


README

此软件包仍在开发中。可能还会进行破坏性更改!此软件包允许您轻松地将Reloadly空气时间/数据API集成到您的应用程序中。

安装

composer require tobexkee/reloadly-php

演示

您可以在PHPSandbox上测试演示

<iframe src="https://phpsandbox.io/e/x/96yon?&layout=EditorPreview&iframeId=0p92l0kt4b&theme=dark&defaultPath=/&showExplorer=yes" style="display: block" loading="lazy" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" height="100%" width="100%"></iframe>

使用方法

首先实例化类的对象。

<?php
  require "vendor/autoload.php";
  use Tobexkee\Reloadly\Reloadly;
  
  
  $client = new Reloadly($client_id, $client_secret, $audience);
  

audience参数的默认值为sandbox。将其设置为live以上线

可用方法

该软件包涵盖了所有可用的reloadly API。

国家

要访问国家API,请使用country方法。这将返回Country API类的实例,因此您可以调用fetch方法以检索国家。

<?php
$countries = $reloadly->countries()->fetch();

您也可以通过ISO检索单个国家

<?php
$country = $reloadly->countries()->fetch('NG');

交易

您可以通过在客户端调用transactions方法来检索交易。这将返回transactions API类的实例,因此您可以调用fetch方法以检索交易。

$transactions = $reloadly->transactions()->fetch();

您也可以使用ID检索单个交易

$transactions = $reloadly->transactions()->fetch($transaction_id);

充值

topup方法返回Topup API类的实例,您可以通过调用send方法向用户发送空气时间或数据。

$sendTopup = $reloadly->topup()->send($data);

$data参数是从relaodly API期望的参数

FX汇率

fxrate方法返回Fxrate API类的实例。在它上面调用fetch方法可以检索预期交易的汇率。

$rate = $reloadly->fxrate()->fetch($operatorId,  $amount);

促销

客户端上的promotions方法返回Promotions API类的实例,允许您根据不同的参数检索可用的促销活动。

$promotions = $reloadly->promotions()->fetchById($id);

$promotions = $reloadly->promotions()->fetchByCountry($country_code);

$promotions = $reloadly->promotions()->fetchByOperator($operator);

$promotions = $reloadly->promotions()->fetch($data); //returns all promotions based all filters set in the $data array

###运营商

$operators = $reloadly->operators()->fetch(); //fetch all operators.

$operators = $reloadly->operators()->fetchById($id); //fetch operator by ID 

$operators = $reloadly->operators()->fetchByIso($iso); //fetch operator by ISO

$operators = $reloadly->operators()->fetchByPhone($phone, $country_iso); //fetch operator by phone number

客户端上的operators方法返回Operators API类的实例,提供了不同方法来检索运营商的详细信息。

折扣

客户端上的discount方法返回Discount API类的实例,具有两个方法,允许您从折扣API检索数据。

$discounts = $reloadly->discount()->fetch(); //fetch all discounts

$discount = $reloadly->discount()->fetchById($id); //fetch discount by ID

账户

客户端上的account方法返回Account API类的实例,其中包含一个balance方法,用于检索您的账户余额。

$balance = $reloadly->account()->balance();

贡献

如果您想为此项目做出贡献,请立即fork并开始提交您的PR。