Created
November 23, 2012 08:46
-
-
Save fontanka16/4134601 to your computer and use it in GitHub Desktop.
example of json.decode
This file contains hidden or 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.Collections.Generic; | |
using System.Linq; | |
using System.Net; | |
using System.Text; | |
using System.Web.Helpers; | |
namespace bibliotekarien.GooglePlus | |
{ | |
public class ActivitiesFetcher | |
{ | |
public static bool GetActivities(string userId, string apiKey, int numberOfItems, out dynamic activities) | |
{ | |
string requestString = "https://www.googleapis.com/plus/v1/people/{0}/activities/public?key={1}&maxResults={2}"; | |
try | |
{ | |
WebRequest request = WebRequest.Create(String.Format(requestString,userId,apiKey, numberOfItems)); | |
request.Method = "GET"; | |
System.Net.WebResponse resp = request.GetResponse(); | |
System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream()); | |
string s = sr.ReadToEnd().Trim(); | |
activities = Json.Decode(s); | |
return true; | |
} | |
catch (Exception ee) | |
{ | |
activities = null; | |
return false; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment