当前位置: 首页>>代码示例>>C#>>正文


C# api.Session类代码示例

本文整理汇总了C#中com.reddit.api.Session的典型用法代码示例。如果您正苦于以下问题:C# Session类的具体用法?C# Session怎么用?C# Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Session类属于com.reddit.api命名空间,在下文中一共展示了Session类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetFlair

        /// <summary>
        /// 
        /// </summary>
        /// <param name="session"></param>
        /// <param name="sub"></param>
        /// <see cref="https://github.com/reddit/reddit/wiki/API%3A-flairlist"/>
        /// <returns></returns>
        public static FlairListing GetFlair(Session session, string sub, string after, string before)
        {
            // var url = "http://www.reddit.com/api/flairlist?r=" + sub + "&limit=1000&uh=" + session.ModHash;
            var url = "http://www.reddit.com/r/" + sub + "/api/flairlist.json?uh=" + session.ModHash + "&limit=1000";
            if (!string.IsNullOrEmpty(after))
                url += "&after=" + after;

            if (!string.IsNullOrEmpty(before))
                url += "&before=" + before;

            var request = new Request
            {
                Url = url,
                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);

            // convert to a post listing
            var list = FlairListing.FromJson(o["users"]);
            list.Next = o["next"] == null ? string.Empty : o["next"].ToString();
            list.Prev = o["prev"] == null ? string.Empty : o["prev"].ToString();
            return list;
        }
开发者ID:openemma,项目名称:reddit,代码行数:36,代码来源:Flair.cs

示例2: Report

        /// <summary>
        /// 
        /// </summary>
        /// <param name="session"></param>
        /// <param name="id"></param>
        /// <see cref="https://github.com/reddit/reddit/wiki/API:-report"/>
        internal static void Report(Session session, string id, string modhash)
        {
            // POST

            // id = post thing id
            // uh = modhash
        }
开发者ID:openemma,项目名称:reddit,代码行数:13,代码来源:Thing.cs

示例3: Query

        public static PostListing Query(Session session, string qry, string after, string before)
        {
            var request = new Request
            {
                Url = "http://www.reddit.com/search.json?q=" + qry,
                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 PostListing.FromJson(o);
        }
开发者ID:openemma,项目名称:reddit,代码行数:16,代码来源:Search.cs

示例4: GetPosts

        public static PostListing GetPosts(Session session)
        {
            var request = new Request
            {
                Url = "http://www.reddit.com/r/friends/.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 PostListing.FromJson(o);
        }
开发者ID:openemma,项目名称:reddit,代码行数:16,代码来源:Friend.cs

示例5: List

        // List submissions from friends
        /// http://www.reddit.com/r/friends/.json
        /// 
        public static UserListing List(Session session)
        {
            var request = new Request
            {
                Url = "https://ssl.reddit.com/prefs/friends.json",
                Method = "GET",
                Cookie = session.Cookie
            };

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

            var o = JObject.Parse(json);
            var list = UserListing.FromJson(o);
            return list;
        }
开发者ID:openemma,项目名称:reddit,代码行数:20,代码来源:Friend.cs

示例6: UnHide

        internal static void UnHide(Session session, string id, string modhash)
        {
            var request = new Request
            {
                Url = "http://www.reddit.com/api/unhide",
                Method = "POST",
                Content = "uh=" + modhash + "&id=" + id,
                Cookie = session.Cookie
            };

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

            if (json != "{}")
                throw new Exception(json);
        }
开发者ID:openemma,项目名称:reddit,代码行数:17,代码来源:Thing.cs

示例7: FromUrl

        /// <summary>
        /// Get information about a URL or domain, find all the stories and comments 
        /// associated within.
        /// </summary>
        /// <param name="session"></param>
        /// <param name="url"></param>
        /// <returns></returns>
        public static PostListing FromUrl(Session session, string url)
        {
            // build the request
            var request = new Request
            {
                Url = "http://www.reddit.com/api/info.json?url=" + url,
                Method = "GET",
                Cookie = session.Cookie
            };

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

            // convert to a post listing
            var o = JObject.Parse(json);
            return PostListing.FromJson(o);
        }
开发者ID:openemma,项目名称:reddit,代码行数:26,代码来源:Info.cs

示例8: Add

        public static void Add(Session session, string username, string id, string modhash)
        {
            id = id.StartsWith("t2_") ? id : "t2_" + id;

            var request = new Request
            {
                Url = "http://www.reddit.com/api/friend?note=",
                Method = "POST",
                Cookie = session.Cookie,
                Content = "name=" + username +
                          "&container=" + id +
                          "&type=friend" +
                          "&uh=" + modhash +
                          "&renderstyle=html"
            };

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

            var o = JObject.Parse(json);
            // o["jquery"][20][3][0].ToString()
        }
开发者ID:openemma,项目名称:reddit,代码行数:23,代码来源:Friend.cs

示例9: List

        /// <summary>
        /// 
        /// </summary>
        /// <param name="session"></param>
        /// <param name="sub"></param>
        /// <param name="after"></param>
        /// <param name="before"></param>
        /// <returns></returns>
        public static SubListing List(Session session, string after = "", string before = "")
        {
            var request = new Request
            {
                Url = "http://www.reddit.com/reddits/.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 SubListing.FromJson(o);
        }
开发者ID:p00rleno,项目名称:reddit-bot-public,代码行数:24,代码来源:Sub.cs

示例10: VoteUp

 public static void VoteUp(Session session, string id, string modhash)
 {
     Thing.VoteUp(session, id, modhash);
 }
开发者ID:TaNeRs,项目名称:SSSS,代码行数:4,代码来源:Post.cs

示例11: Vote

        private static void Vote(Session session, string id, string modhash, int direction)
        {
            var request = new Request
            {
                Url = "http://www.reddit.com/api/vote",
                Method = "POST",
                Content = "uh=" + modhash + "&id=" + id + "&dir=" + direction.ToString(),
                Cookie = session.Cookie
            };

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

            if (json != "{}")
                throw new Exception(json);
        }
开发者ID:openemma,项目名称:reddit,代码行数:17,代码来源:Thing.cs

示例12: Read

        public static void Read(Session session, params string[] id)
        {
            var request = new Request
            {
                Url = "http://www.reddit.com/api/read_message",
                Method = "POST",
                Cookie = session.Cookie,
                Content = "id=" + string.Join(",", id) + "&uh=" + session.ModHash
            };

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

            var o = JObject.Parse(json);
        }
开发者ID:anthony-france,项目名称:RedditToast,代码行数:16,代码来源:Message.cs

示例13: BanUser

        public static void BanUser(Session session, string sub, string sub_id, string username, string modhash)
        {
            var request = new Request
            {
                Url = "http://www.reddit.com/api/friend",
                Method = "POST",
                Cookie = session.Cookie,
                Content = "action=add" +
                          "&container=" + sub_id +
                          "&type=banned" +
                          "&name=" + username +
                          "&id=#banned" +
                          "&r=" + sub +
                          "&uh=" + modhash +
                          "&renderstyle=html"
            };

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

            var o = JObject.Parse(json);
        }
开发者ID:p00rleno,项目名称:reddit-bot-public,代码行数:23,代码来源:Sub.cs

示例14: VoteNull

 internal static void VoteNull(Session session, string id, string modhash)
 {
     Vote(session, id, modhash, 0);
 }
开发者ID:openemma,项目名称:reddit,代码行数:4,代码来源:Thing.cs

示例15: GetRelated

        public static PostListing GetRelated(Session session, string id)
        {
            // Make sure we process the request with the type removed, so
            // we just pass the base-36 ID
            id = id.Replace("t3_", string.Empty);

            // build a request
            var request = new Request
            {
                Url = "http://www.reddit.com/related/" + id + ".json",
                Cookie = session.Cookie
            };

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

            return JsonConvert.DeserializeObject<PostListing>(json);
        }
开发者ID:TaNeRs,项目名称:SSSS,代码行数:19,代码来源:Post.cs


注:本文中的com.reddit.api.Session类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。