Created
February 27, 2010 04:46
-
-
Save Arthraim/316481 to your computer and use it in GitHub Desktop.
dotnet renjian api request example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Net; | |
namespace HttpRequest | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
try | |
{ | |
WebRequest request = WebRequest.Create("http://api.renjian.com/statuses/followings.json"); | |
request.Credentials = new NetworkCredential("username", "password"); | |
HttpWebResponse response = (HttpWebResponse)request.GetResponse(); | |
Stream dataStream = response.GetResponseStream(); | |
StreamReader reader = new StreamReader(dataStream); | |
string responseFromServer = reader.ReadToEnd(); | |
Console.WriteLine(responseFromServer); | |
reader.Close(); | |
dataStream.Close(); | |
response.Close(); | |
} | |
catch (System.Net.WebException ex) | |
{ | |
Console.WriteLine(ex.Message); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment