Exemple #1
0
        public static Sub Get(Session session, string sub)
        {
            //
            var request = new Request
            {
                Url    = "http://www.reddit.com/r/" + sub + "/about/.json",
                Method = "GET",
                Cookie = session.Cookie
            };

            var json = string.Empty;

            if (request.Execute(out json) != System.Net.HttpStatusCode.OK)
            {
                throw new RedditException(json);
            }

            var o = JObject.Parse(json);

            return(Sub.FromJson(o["data"]));
        }
Exemple #2
0
        public static void Create(Session session, Sub sub)
        {
            var subreddit_type  = "public";
            var language        = "en";
            var content_options = "any";
            var over_18         = false;
            var default_set     = true;
            var show_media      = false;
            var domain          = "";

            var request = new Request
            {
                Url     = "",
                Method  = "POST",
                Cookie  = session.Cookie,
                Content = "name=" + sub.Name +
                          "&title=" + sub.Title +
                          "&description=" + sub.Description +
                          "&lang=" + language +
                          "&type=" + subreddit_type +
                          "&link_type=" + content_options +
                          "&over_18=" + (over_18 ? "on" : "off") +
                          "&allow_top=" + (default_set ? "on" : "off") +
                          "&show_media=" + (show_media ? "on" : "off") +
                          "&domain=" + domain +
                          "&uh=" + session.ModHash +
                          "&id=#sr-form&api_type=json"
            };

            var json = string.Empty;

            if (request.Execute(out json) != System.Net.HttpStatusCode.OK)
            {
                throw new RedditException(json);
            }

            var o = JObject.Parse(json);
        }
Exemple #3
0
        public static void Create(Session session, Sub sub)
        {
            var subreddit_type = "public";
            var language = "en";
            var content_options = "any";
            var over_18 = false;
            var default_set = true;
            var show_media = false;
            var domain = "";

            var request = new Request
            {
                Url = "",
                Method = "POST",
                Cookie = session.Cookie,
                Content = "name=" + sub.Name +
                          "&title=" + sub.Title +
                          "&description=" + sub.Description +
                          "&lang=" + language +
                          "&type=" + subreddit_type +
                          "&link_type=" + content_options +
                          "&over_18=" + (over_18 ? "on" : "off") +
                          "&allow_top=" + (default_set ? "on" : "off") +
                          "&show_media=" + (show_media ? "on" : "off") +
                          "&domain=" + domain +
                          "&uh=" + session.ModHash +
                          "&id=#sr-form&api_type=json"
            };

            var json = string.Empty;
            if (request.Execute(out json) != System.Net.HttpStatusCode.OK)
                throw new RedditException(json);

            var o = JObject.Parse(json);
        }