moneymeg / starling-php-sdk
此包的最新版本(1.0)没有可用的许可信息。
Starling 银行 API 的 PHP SDK。
1.0
2017-11-23 12:14 UTC
Requires
- guzzlehttp/guzzle: ~6.0
Requires (Dev)
This package is not auto-updated.
Last update: 2024-09-29 04:36:53 UTC
README
这是一个 Starling SDK 的 SDK,你需要自己处理从用户那里获取令牌,但是一旦你有了令牌,这个 SDK 就会封装整个 API,以允许在 PHP 中方便使用。
目前它只有只读功能,当我需要使用时我会添加一些写入功能。
请参阅测试文件夹中的所有请求,如果你想编写自己的,它们需要实现 RequestInterface 接口。
我不想表达太多个人意见,所以响应没有格式化。
安装
composer require moneymeg/starling-php-sdk
测试
$ ./vendor/bin/phpunit
获取用户余额
$identity = new Starling\Identity($client_token); $client = new Starling\Api\Client($identity, ['env' => 'prod']); $request = new Starling\Api\Request\Accounts\Balance(); try { $result = $client->request($request); $body = json_decode((string) $result->getBody(), true); print "Your balance is " . $body['effectiveBalance'] . " as for right now."; } catch (Exception $e) { print $e->getMessage(); }
获取用户账户详情
$identity = new Starling\Identity($client_token); $client = new Starling\Api\Client($identity, ['env' => 'prod']); $request = new Starling\Api\Request\Accounts(); try { $result = $client->request($request); $body = json_decode((string) $result->getBody(), true); print $body; } catch (Exception $e) { print $e->getMessage(); }
获取客户的直接借记
$identity = new Starling\Identity($client_token); $client = new Starling\Api\Client($identity, ['env' => 'prod']); $request = new Starling\Api\Request\DirectDebits(); try { $result = $client->request($request); $body = json_decode((string) $result->getBody(), true); print $body; } catch (Exception $e) { print $e->getMessage(); }
获取过去 7 天的交易
$identity = new Starling\Identity($client_token); $client = new Starling\Api\Client($identity); $request = new Starling\Api\Request\Transactions([ 'from' => new DateTime("-7 Days"), 'to' => new DateTime(), ]); try { $result = $client->request($request); $body = json_decode((string) $result->getBody(), true); print $body; } catch (Exception $e) { print $e->getMessage(); }