Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I Have URL Like:
http://data.mtgox.com/api/1/BTCUSD/ticker[^]

while i used the like below:
C#
public void getValues()
{
    HttpWebRequest request = WebRequest.Create("http://data.mtgox.com/api/1/BTCUSD/ticker") as HttpWebRequest;
    using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
    {
        StreamReader reader = new StreamReader(response.GetResponseStream());
        string s = reader.ReadToEnd().ToString();
        Response.Write(s);
    }
}

With Above function some time i get the problem
[The operation has timed out] or [remote server not found]

------------------------------------------------------------------------------------------------

and with help of [http://data.mtgox.com/api/1/BTCUSD/ticker[^]] url help me out.

if any other method then suggest

need it friends
Posted
Updated 4-Apr-13 1:55am
v8
Comments
ZurdoDev 3-Apr-13 9:11am    
It looks like json so you could use some json methods. Or just parse it using string methods.

1 solution

You have a JSON string there. You can follow this article to read it: http://aspdotnet.hotinit.com/2012/01/get-json-data-from-url.html[^] and than you have to choose how to process the string. I suggest you consult following article for a comparison of JSON libraries: fastJSON[^] - and of course, a good one to use for deserialization. If you have deserialized it to a collection of objects, you can simply query that with linq. This is also one interesting approach: http://james.newtonking.com/projects/json/help/index.html?topic=html/LINQtoJSON.htm[^]
 
Share this answer
 
Comments
Jimmy Darji 3-Apr-13 10:17am    
Thanks for answering
i am trying but not worked
Zoltán Zörgő 3-Apr-13 13:25pm    
What have you tried?
Zoltán Zörgő 3-Apr-13 13:49pm    
Oh yes. I see. Your server requires "User-Agent" in the request. Actually any will do. Just add
request.UserAgent = "None";
before the using construct.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900