简体   繁体   English

如何在不使用PubNub库的情况下使用PubNub和MtGox api?

[英]How to work with PubNub and MtGox api without using PubNub libraries?

I'm writing an app in Dart, which PubNub has no libraries for. 我在Dart写了一个应用程序,PubNub没有库。 My question is, would it be possible to interact with MtGox api (which is, as far as I understand, built on PubNub) using Websockets? 我的问题是,是否可以使用Websockets与MtGox api(据我所知,建立在PubNub上)进行交互? How does PubNub relate to Websockets? PubNub如何与Websockets相关? Their documentation mostly advertises their SDK libraries. 他们的文档主要是宣传他们的SDK库。 I'm rather confused where to start. 我很困惑从哪里开始。

PubNub Dart Subscribe to Mt.Gox Bitcoin Feed PubNub Dart订阅Mt.Gox比特币Feed

The question ask about how to use the PubNub Real-Time Network without an SLA officially supported SDK provided by PubNub. 问题是如何在没有PubNub提供的SLA官方支持的SDK的情况下使用PubNub实时网络。 We do not recommend this and instead have provided the recommended method which includes using the standard import 'dart:js' library interop. 我们不建议这样做,而是提供了推荐的方法,包括使用标准import 'dart:js'库互操作。 Details follow but if you still want to continue with a non-library method, the docs for the HTTP REST Push API interface will be a general starting point. 详细信息如下,但如果您仍想继续使用非库方法,则HTTP REST Push API接口的文档将是一个通用的起点。 But now we are going onward with the recommended method below! 但现在我们继续使用下面推荐的方法! Please continue reading. 请继续阅读。

Subscribing to the Mt.Gox Bitcoin Real-Time feed using Google Dart is rather simple, though a bit confusing at first. 使用Google Dart订阅Mt.Gox比特币实时订阅源非常简单,但最初有点令人困惑。 Start by setting up your HTML file with the following script tags; 首先使用以下脚本标记设置HTML文件; and don't forget the PubNub <div> ! 并且不要忘记PubNub <div>

PubNub Dart订阅Mt.Gox比特币Feed

PubNub Dart HTML File Example PubNub Dart HTML文件示例

<h1>PubNub Dart JavaScript SDK Usage Example</h1>

<div id="pubnub" sub-key="sub-c-50d56e1e-2fd9-11e3-a041-02ee2ddab7fe"></div>
<script src="https://cdn.pubnub.com/pubnub.min.js"></script>

<script type="application/dart" src="pubnub_sample.dart"></script>
<script src="packages/browser/dart.js"></script>
<script src="packages/browser/interop.js"></script>

NOTE: The PubNub <div> includes the Mt.Gox Subscribe Key paramater. 注意: PubNub <div>包括Mt.Gox 订阅密钥参数。

PubNub Dart Source File and SDK Usage Subscribe Callback Example PubNub Dart源文件和SDK用法订阅回调示例

Next your Dart app source code will simply open the TCP Socket to the live stream. 接下来,您的Dart应用程序源代码将只打开TCP Socket到实时流。 Note the channel ID is d5f06780-30a8-4a48-a2f8-7ed181b4a13f . 注意,通道ID是d5f06780-30a8-4a48-a2f8-7ed181b4a13f This is one of many channel streams provided by Mt.Gox which allow you to receive Trade/Depth/Ticker signals. 这是Mt.Gox提供的众多频道流之一,允许您接收交易/深度/股票信号。

PubNub Dart Source File PubNub Dart源文件

import 'dart:js';

void main() {
  context['PUBNUB'].callMethod( 'subscribe', [new JsObject.jsify({
    "channel" : "d5f06780-30a8-4a48-a2f8-7ed181b4a13f",
    "message" : ( message, env, channel, age ) => print(message)
  })] );
}

That's it! 而已! You can start receiving live Real-Time signals from Mt.Gox using this method. 您可以使用此方法开始从Mt.Gox接收实时实时信号。 Also you'll want to add or change the channel for different types of events. 此外,您还需要为不同类型的活动添加或更改频道。

NOTE: You can find more Mt.Gox Channels by requesting the channel listing API call: PubNub Mt.Gox Channel Stream Feed Listing for Ticker/Trade/Depth Signals 注意:您可以通过请求频道列表API调用找到更多Mt.Gox频道: PubNub用于Ticker /交易/深度信号的Mt.Gox频道流Feed列表

PubNub Mt.Gox Ticker / Trade / Depth Signals的渠道流源列表

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM