简体   繁体   English

C#MtGox值捕获器

[英]C# MtGox Value Grabber

Okay guys, here's the deal. 好的,这是交易。 I'm a total C# beginner but I've been advised to learn it. 我是C#的初学者,但建议我学习它。 I'm desperate to get a working Bitcoin value grabber going - so that I can record the values to a text file. 我迫不及待地想要工作一个比特币价值采集器-这样我就可以将这些值记录到一个文本文件中。 Another thing is that the value must be from MtGox, either their API or their homepage. 另一件事是,该值必须来自MtG​​ox,无论是其API还是其首页。

I've spent a while dealing with HTTP requests and JSON decoding (grrr...) but I don't see the point in me spending so much time on my learning code when I'm sure there is someone else out there who can just help me to write it. 我花了一段时间处理HTTP请求和JSON解码(grrr ...),但是当我确定还有其他人可以花时间在我的学习代码上时,我看不出我要花多少时间帮我写就好。

Does anyone think they might be able to help with this? 有人认为他们可能对此有所帮助吗? Just a couple of lines to pull the last Bitcoin value from MtGox. 仅需几行代码,即可从MtGox获得最后的比特币价值。

Any contributions are much appreciated. 非常感谢任何贡献。 Will. 将。

EDIT: 编辑:

var json = WebClient.DownloadString("http://data.mtgox.com/api/2/BTCUSD/money/ticker_fast");

string valueOriginal = Convert.ToString(json);

That is all I needed to write. 那就是我需要写的。 Wow. 哇。 Thanks for the help though, Oliver. 谢谢您的帮助,奥利弗(Oliver)。

This is a Q&A site, so don't expect other's to write your code for you. 这是一个问答网站,所以不要指望别人为您编写代码。

You can access their API using any language that supports HTTP calls. 您可以使用任何支持HTTP调用的语言来访问其API。 Here's a great document to get you started: MtGOX api docs 这是一个很好的入门指南: MtGOX api文档

This is a judgement call, but it sounds like you're new to programming in general. 这是一个判断电话,但听起来您是一般编程新手。 Don't commit yourself to a language. 不要致力于某种语言。 Always use the best tool for the job. 始终使用最好的工具完成工作。 I'd suggest using something a bit more "web friendly" for this sort of work. 我建议对这种工作使用一些“网络友好”的东西。 NodeJS would make this much easier for you as it understands the JSON returned from their API nativly, without using all sorts of wrappers and instances of the WebClient class or HttpResponseMessages as you do in .NET. NodeJS可以很自然地理解从其API返回的JSON,因此无需您像在.NET中那样使用WebClient类或HttpResponseMessages的各种包装和实例,从而使您的工作更加轻松。 Also consider the purpose of writing the data to a text file. 还应考虑将数据写入文本文件的目的。 What is going to consume that data? 什么会消耗这些数据? It's possible that you can skip the file and just interact with the down-level consumer directally. 您可能会跳过文件,而直接与下级使用者进行交互。

What format needs to be in the data file? 数据文件中应采用什么格式? If you can save it in JSON, you could do this in C# 如果可以将其保存为JSON,则可以在C#中执行此操作

using System.Net;
//...
WebClient Client = new WebClient ();
Client.DownloadFile("https://mtgox.com/api/1/BTCUSD/ticker", @"C:\folder\results.json");

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

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