黄金数据查询演示示例
using System;
using System.Text;
using System.Net;
namespace gold
{
class Program
{
static void Main(string[] args)
{
string key = "*****************";//申请的key值
string url = "http://apis.haoservice.com/lifeservice/gold/shgold?key="+ key;
WebClient wc = new WebClient();
wc.Encoding = Encoding.UTF8;
string str = wc.DownloadString(url);
Console.WriteLine(str);
Console.ReadKey();
}
}
}
URL:http://apis.haoservice.com/lifeservice/gold/shgold
支持格式:json
http请求方式:GET POST
DEMO:http://apis.haoservice.com/lifeservice/gold/shgold?key=您申请的APPKEY
返回示例:
{
"error_code":"0",
"reason":"Success!",
"result":[
{
"1":{
"variety":"Ag(T+D)", /*品种*/
"latestpri":"6585.00", /*最新价*/
"openpri":"6712.00", /*开盘价*/
"maxpri":"6721.00", /*最高价*/
"minpri":"6581.00", /*最低价*/
"limit":"-1.98%", /*涨跌幅*/
"yespri":"6718.00", /*昨收价*/
"totalvol":"1564524.0000", /*总成交量*/
"time":"2012-12-19 15:29:59" /*更新时间*/
},
......
"7":{
"variety":"Au99.99",
"latestpri":"336.77",
"openpri":"342.00",
"maxpri":"342.00",
"minpri":"336.40",
"limit":"-1.53%",
"yespri":"342.00",
"totalvol":"6936.2000",
"time":"2012-12-19 15:29:53"
}
......
}
]
}
备注:
黄金数据查询,只用申请key值即可;
若出现错误,请查看该网页(http://www.haoservice.com/docs/22)上的代码表.