Beispiel #1
0
        public async Task <LoginResult> LoginResult(string username, string password)
        {
            WebContentProvider web     = WebContentProvider.GetInstance();
            string             content = string.Format("email={0}&password={1}", Uri.EscapeDataString(username), Uri.EscapeDataString(password));

            return(await web.HttpPostRequest <LoginResult>(Config.JianShuLogin, content, web.GetHeaders(null, null)));
        }
Beispiel #2
0
        public async Task <List <TrendingResult> > TrendingResult(string frequency, int index, int count)
        {
            WebContentProvider web  = WebContentProvider.GetInstance();
            string             text = string.Format(Config.Trending, frequency, index, count);

            return(await web.HttpGetRequest <List <TrendingResult> >(text, web.GetHeaders(null, null)));
        }
Beispiel #3
0
        public async Task <NoteDetailResult> NoteDetailResult(string noteId, string user_id, string mobile_token)
        {
            WebContentProvider web  = WebContentProvider.GetInstance();
            string             text = string.Format(Config.NoteDetail, noteId);

            return(await web.HttpGetRequest <NoteDetailResult>(text, web.GetHeaders(null, null)));
        }
        /// <summary>
        /// Query comment
        /// </summary>
        /// <param name="noteId">Note Id</param>
        /// <param name="startid">Start Id</param>
        /// <returns></returns>
        public async Task <List <CommentsResult> > QueryComment(string noteId, int startid)
        {
            WebContentProvider web = WebContentProvider.GetInstance();
            string             url = string.Format(Config.GetComments, noteId, 20, 20);

            if (startid != 0)
            {
                url += "&max_id=" + startid;
            }
            return(await web.HttpGetRequest <List <CommentsResult> >(url, web.GetHeaders(null, null)));
        }
        /// <summary>
        /// Query subscription notes
        /// </summary>
        /// <param name="startid">Start Id</param>
        /// <param name="userid">User Id</param>
        /// <param name="mobiletoken">Mobile Token</param>
        /// <returns></returns>
        public async Task <List <SubscriptionNotesResult> > QuerySubscriptionNotes(int startid, string userid, string mobiletoken)
        {
            WebContentProvider web = WebContentProvider.GetInstance();
            string             url = Config.SubscriptionNotes;

            if (startid != 0)
            {
                url += "&max_received_at=" + startid;
            }
            return(await web.HttpGetRequest <List <SubscriptionNotesResult> >(url, web.GetHeaders(userid, mobiletoken)));
        }
        /// <summary>
        /// Query topic's last notes
        /// </summary>
        /// <param name="topicId">Topic ID</param>
        /// <param name="startid">Start ID</param>
        /// <returns></returns>
        public async Task <List <TopicLastResult> > QueryTopicLast(string topicId, int startid)
        {
            WebContentProvider web = WebContentProvider.GetInstance();
            string             url = string.Format(Config.TopicNewestNotes, topicId);

            if (startid != 0)
            {
                url += "&max_id=" + startid;
            }
            return(await web.HttpGetRequest <List <TopicLastResult> >(url, web.GetHeaders(null, null)));
        }
        /// <summary>
        /// Query user's activities
        /// </summary>
        /// <param name="startid">The activity id that start</param>
        /// <param name="userid">User Id</param>
        /// <param name="mobiletoken">Mobile Token</param>
        /// <returns></returns>
        public async Task <List <ActivityResult> > QueryActivities(int startid, string userid, string mobiletoken)
        {
            WebContentProvider web = WebContentProvider.GetInstance();
            string             url = string.Format(Config.QueryActivities, userid);

            if (startid != 0)
            {
                url += "&max_id=" + startid;
            }
            return(await web.HttpGetRequest <List <ActivityResult> >(url, web.GetHeaders(userid, mobiletoken)));
        }
        /// <summary>
        /// Query Topic
        /// </summary>
        /// <param name="type">Type</param>
        /// <param name="index">Index</param>
        /// <param name="userid">User Id</param>
        /// <param name="mobiletoken">Mobile Token</param>
        /// <returns></returns>
        public async Task <List <DiscoverResult> > QueryTopic(TopicType type, int index, string userid, string mobiletoken)
        {
            WebContentProvider web = WebContentProvider.GetInstance();
            string             url = string.Format(Config.Discover, index);

            if (type != TopicType.None)
            {
                url += "&category_id=" + (int)type;
            }
            return(await web.HttpGetRequest <List <DiscoverResult> >(url, web.GetHeaders(userid, mobiletoken)));
        }
        /// <summary>
        /// Query notifies your want
        /// </summary>
        /// <param name="page">Page</param>
        /// <param name="types">Tyeps you want</param>
        /// <param name="userid">User Id</param>
        /// <param name="mobiletoken">Mobile Token</param>
        /// <returns></returns>
        public async Task <List <NotifyResult> > QueryNotify(int page, List <string> types, string userid, string mobiletoken)
        {
            WebContentProvider web = WebContentProvider.GetInstance();
            string             url = string.Format(Config.Notifications, page);

            if (types != null && types.Count > 0)
            {
                foreach (string str in types)
                {
                    url += "&types[]=" + str;
                }
            }
            return(await web.HttpGetRequest <List <NotifyResult> >(url, web.GetHeaders(userid, mobiletoken)));
        }
Beispiel #10
0
        /// <summary>
        /// Query topic notes
        /// </summary>
        /// <param name="type">Topic Type</param>
        /// <param name="startid">Start Id</param>
        /// <returns></returns>
        public async Task <List <RecommendationResult> > QueryDiscover(TopicType type, int startid)
        {
            WebContentProvider web = WebContentProvider.GetInstance();
            string             url = Config.Recommendations;

            if (type != TopicType.None)
            {
                url += "&collection_category_id=" + (int)type;
            }
            if (startid != 0)
            {
                url += "&max_recommended_at=" + startid;
            }
            return(await web.HttpGetRequest <List <RecommendationResult> >(url, web.GetHeaders(null, null)));
        }
Beispiel #11
0
        /// <summary>
        /// Query hot topic notes
        /// </summary>
        /// <param name="frequency">Frequency</param>
        /// <param name="index">Index</param>
        /// <param name="count">Count</param>
        /// <returns></returns>
        public async Task <List <TrendingResult> > QueryDiscover(HotTopicType frequency, int index, int count, List <TrendingResult> seen = null)
        {
            WebContentProvider web  = WebContentProvider.GetInstance();
            string             text = string.Format(Config.Trending, frequency.ToString(), index, count);

            if (seen?.Count > 0)
            {
                StringBuilder sb = new StringBuilder();
                foreach (TrendingResult i in seen)
                {
                    sb.Append("&seen_note_ids[]=" + i.Id);
                }
                text += sb.ToString();
            }
            return(await web.HttpGetRequest <List <TrendingResult> >(text, web.GetHeaders(null, null)));
        }
        /// <summary>
        /// Query base user info
        /// </summary>
        /// <param name="userid">User Id</param>
        /// <param name="mobiletoken">Mobile Token</param>
        /// <returns></returns>
        public async Task <UserBaseInfo> QueryBaseInfo(string userid, string mobiletoken)
        {
            WebContentProvider web = WebContentProvider.GetInstance();

            return(await web.HttpGetRequest <UserBaseInfo>(Config.BaseInfo, web.GetHeaders(userid, mobiletoken)));
        }
        /// <summary>
        /// Query Ohter's Subscription
        /// </summary>
        /// <param name="otherid">Other Id</param>
        /// <param name="userid">User Id</param>
        /// <param name="mobiletoken">Mobile Token</param>
        /// <param name="index">Index</param>
        /// <returns></returns>
        public async Task <List <Subscription> > QueryOhterSubscription(string otherid, string userid, string mobiletoken, int index)
        {
            WebContentProvider web = WebContentProvider.GetInstance();

            return(await web.HttpGetRequest <List <Subscription> >(string.Format(Config.Subscriptions, otherid, index), web.GetHeaders(userid, mobiletoken)));
        }
        /// <summary>
        /// Query feed message
        /// </summary>
        /// <param name="userid">User Id</param>
        /// <param name="mobiletoken">Mobile Token</param>
        /// <returns></returns>
        public async Task <List <FeedsMsgResult> > QueryFeedMsg(string userid, string mobiletoken)
        {
            WebContentProvider web = WebContentProvider.GetInstance();

            return(await web.HttpGetRequest <List <FeedsMsgResult> >(Config.FeedsMsg, web.GetHeaders(userid, mobiletoken)));
        }
        /// <summary>
        /// Query note detail
        /// </summary>
        /// <param name="noteId">Note Id</param>
        /// <returns></returns>
        public async Task <NoteDetailResult> QueryNoteDetail(string noteId, string userid, string mobiletoken)
        {
            WebContentProvider web = WebContentProvider.GetInstance();

            return(await web.HttpGetRequest <NoteDetailResult>(string.Format(Config.NoteDetail, noteId), web.GetHeaders(userid, mobiletoken)));
        }
        /// <summary>
        /// Add comment
        /// </summary>
        /// <param name="noteid">Note Id</param>
        /// <param name="content">Content</param>
        /// <param name="userid">User Id</param>
        /// <param name="mobiletoken">Mobile Token</param>
        /// <returns></returns>
        public async Task <AddCommentResult> AddComment(string noteid, string content, string userid, string mobiletoken)
        {
            WebContentProvider web = WebContentProvider.GetInstance();

            return(await web.HttpPostRequest <AddCommentResult>(string.Format(Config.AddComment, noteid), "&content=" + content, web.GetHeaders(userid, mobiletoken)));
        }
        /// <summary>
        /// Query people that other's followered
        /// </summary>
        /// <param name="page">Page</param>
        /// <param name="otherid">Ohter's User Id</param>
        /// <param name="userid">User Id</param>
        /// <param name="mobiletoken">Mobile Token</param>
        /// <returns></returns>
        public async Task <List <FollowUserInfo> > QueryFollowingUsers(int page, string otherid, string userid, string mobiletoken)
        {
            WebContentProvider web = WebContentProvider.GetInstance();

            return(await web.HttpGetRequest <List <FollowUserInfo> >(string.Format(Config.Following, otherid, page), web.GetHeaders(userid, mobiletoken)));
        }
        /// <summary>
        /// Unfollow user
        /// </summary>
        /// <param name="followuserid">Follow User Id</param>
        /// <param name="userid">User Id</param>
        /// <param name="mobiletoken">Mobile Token</param>
        /// <returns></returns>
        public async Task <FollowResult> UnFollowUser(string followuserid, string userid, string mobiletoken)
        {
            WebContentProvider web = WebContentProvider.GetInstance();

            return(await web.HttpPostRequest <FollowResult>(string.Format(Config.UnFollow, followuserid), "?", web.GetHeaders(userid, mobiletoken)));
        }
        /// <summary>
        /// Set user unlike the note
        /// </summary>
        /// <param name="noteid">Note Id</param>
        /// <param name="userid">User Id</param>
        /// <param name="mobiletoken">Mobile Token</param>
        /// <returns></returns>
        public async Task <LikeResult> UnlikeNote(int noteid, string userid, string mobiletoken)
        {
            WebContentProvider web = WebContentProvider.GetInstance();

            return(await web.HttpPostRequest <LikeResult>(string.Format(Config.UnlikeNote, noteid), "?", web.GetHeaders(userid, mobiletoken)));
        }
        /// <summary>
        /// Query notes that user likes
        /// </summary>
        /// <param name="page">Page</param>
        /// <param name="userid">User Id</param>
        /// <param name="mobiletoken">Mobile Token</param>
        /// <returns></returns>
        public async Task <List <Note> > QueryLikeNotes(int page, string userid, string mobiletoken)
        {
            WebContentProvider web = WebContentProvider.GetInstance();

            return(await web.HttpGetRequest <List <Note> >(string.Format(Config.LikedNotes, userid, page), web.GetHeaders(userid, mobiletoken)));
        }
        /// <summary>
        /// Query user's marked notes
        /// </summary>
        /// <param name="page">Page</param>
        /// <param name="userid">User Id</param>
        /// <param name="mobiletoken">Mobile Token</param>
        /// <returns></returns>
        public async Task <List <BookmarkResult> > QueryBookmark(int page, string userid, string mobiletoken)
        {
            WebContentProvider web = WebContentProvider.GetInstance();

            return(await web.HttpGetRequest <List <BookmarkResult> >(string.Format(Config.Bookmark, page), web.GetHeaders(userid, mobiletoken)));
        }
        /// <summary>
        /// Query other's notebook
        /// </summary>
        /// <param name="page">Page</param>
        /// <param name="userid">User Id</param>
        /// <param name="mobiletoken">Mobile Token</param>
        /// <returns></returns>
        public async Task <List <NotebookResult> > QueryOhterNotebook(string otherid, int page, string userid, string mobiletoken)
        {
            WebContentProvider web = WebContentProvider.GetInstance();

            return(await web.HttpGetRequest <List <NotebookResult> >(string.Format(Config.OhtersNotebooks, otherid, page), web.GetHeaders(userid, mobiletoken)));
        }
        /// <summary>
        /// Unsubscribe collection
        /// </summary>
        /// <param name="dicscoverid"></param>
        /// <param name="userid"></param>
        /// <param name="mobiletoken"></param>
        /// <returns></returns>
        public async Task <DiscoverSubscribeResult> Unsubscribe(int discoverid, string userid, string mobiletoken)
        {
            WebContentProvider web = WebContentProvider.GetInstance();

            return(await web.HttpPostRequest <DiscoverSubscribeResult>(string.Format(Config.Unsubscribe, discoverid), "?", web.GetHeaders(userid, mobiletoken)));
        }
        /// <summary>
        /// Query message count
        /// </summary>
        /// <param name="userid">User Id</param>
        /// <param name="mobiletoken">Mobile Token</param>
        /// <returns></returns>
        public async Task <MsgCountResult> QueryMsgCount(string userid, string mobiletoken)
        {
            WebContentProvider web = WebContentProvider.GetInstance();

            return(await web.HttpGetRequest <MsgCountResult>(Config.UnReadCounts, web.GetHeaders(userid, mobiletoken)));
        }
Beispiel #25
0
        /// <summary>
        /// Query ohter's user info
        /// </summary>
        /// <param name="userid">User Id</param>
        /// <returns></returns>
        public async Task <UserBaseInfo> QueryUserInfo(string userid)
        {
            WebContentProvider web = WebContentProvider.GetInstance();

            return(await web.HttpGetRequest <UserBaseInfo>(string.Format(Config.UserInfo, userid), web.GetHeaders(null, null)));
        }
        /// <summary>
        /// Query user's notes
        /// </summary>
        /// <param name="page">Page</param>
        /// <param name="shared">1:Public article;0:Private article</param>
        /// <param name="userid">User Id</param>
        /// <param name="mobiletoken">Mobile Token</param>
        /// <returns></returns>
        public async Task <List <NoteResult> > QueryNote(int page, int shared, string userid, string mobiletoken)
        {
            WebContentProvider web = WebContentProvider.GetInstance();

            return(await web.HttpGetRequest <List <NoteResult> >(string.Format(Config.Notes, page, shared), web.GetHeaders(userid, mobiletoken)));
        }