forex rmb to php,ForexQuotes 一个用于获取实时外汇报价的PHP库

php-forex-quotes

php-forex-quotes is a PHP Library for fetching realtime forex quotes. See the examples for REST and WebSocket implementation in the /examples folder.

68747470733a2f2f31666f7267652e636f6d2f696d616765732f31666f7267652e676966

Table of Contents

Requirements

PHP >= 6.0.1

An API key which you can obtain for free at http://1forge.com/forex-data-api

Installation

composer require oneforge/forexquotes

Or in your composer.json

"require": {

"oneforge/forexquotes": "^6.0"

},

Usage

Instantiate the client

use OneForge\ForexQuotes\ForexDataClient;

//You can get an API key for free at 1forge.com

$client = new ForexDataClient('YOUR_API_KEY');

Get the list of available symbols:

$client->getSymbols();

Get quotes for specified symbols:

$client->getQuotes([

'AUD/USD',

'GBP/JPY'

]);

Convert from one currency to another:

$client->convert('USD', 'EUR', 100);

Check if the market is open:

if ($client->marketIsOpen())

{

echo "Market is open";

}

Check your usage / quota limit:

$client->quota();

Stream quote updates:

WebSocket quote streaming is only available on paid plans.

//Handle incoming price updates from the server

$client->onUpdate(function($symbol, $data)

{

echo $symbol . ": " . $data["b"] . " " .$data["a"] . " " . $data["p"]."\n";

});

//Handle non-price update messages

$client->onMessage(function($message)

{

echo $message;

});

//Connect to the server

$client->connect(function($client)

{

//Subscribe to a single currency pair

$client->subscribeTo('EUR/USD');

//Subscribe to an array of currency pairs

$client->subscribeTo([

'GBP/JPY',

'AUD/CAD',

'EUR/CHF'

]);

//Subscribe to all currency pairs

$client->subscribeToAll();

//Unsubscribe from a single currency pair

$client->unsubscribeFrom('EUR/USD');

//Unsubscribe from an array of currency pairs

$client->unsubscribeFrom([

'GBP/JPY',

'AUD/CAD',

'EUR/CHF'

]);

//Unsubscribe from all currency pairs

$client->unsubscribeFromAll();

});

Contributing

Thank you for considering contributing! Any issues, bug fixes, suggestions, improvements or help in any other way is always appreciated. Please feel free to open an issue or create a pull request.

Support and Contact

Please contact me at contact@1forge.com if you have any questions or requests.

License and Terms

This library is provided without warranty under the MIT license.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值