Esempio n. 1
0
        public static RedditPost GetPost(int i)
        {
            string     output = GetData();
            RedditPost rp     = new RedditPost(output, i);

            return(rp);
        }
Esempio n. 2
0
        public static RedditPost GetPost(int i)
        {
            string     output = GetData("https://www.reddit.com/r/nba/.json");
            RedditPost rp     = new RedditPost(output, i);

            return(rp);
        }
Esempio n. 3
0
        public static List <RedditPost> GetPosts()
        {
            List <RedditPost> posts  = new List <RedditPost>();
            string            output = GetData();


            JObject redditJson = JObject.Parse(output);

            List <JToken> postTokens = redditJson["data"]["children"].ToList();

            for (int i = 0; i < postTokens.Count; i++)
            {
                RedditPost rp = new RedditPost();

                rp.Title    = postTokens[i]["data"]["title"].ToString();
                rp.ImageURL = postTokens[i]["data"]["thumbnail"].ToString();
                rp.LinkURL  = "http://reddit.com/" + postTokens[i]["data"]["permalink"].ToString();
                posts.Add(rp);
            }

            return(posts);
        }