Beispiel #1
0
        public async Task <bool> PostMessage(string to, string subject, string message, string token)
        {
            var postData = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("message", message),
                new KeyValuePair <string, string>("s", ""),
                new KeyValuePair <string, string>("do", "insertpm"),
                new KeyValuePair <string, string>("recipients[]", to),
                new KeyValuePair <string, string>("title", subject),
                new KeyValuePair <string, string>("receipt", "0"),
                new KeyValuePair <string, string>("signature", "1"),
                new KeyValuePair <string, string>("parseurl", "1"),
                new KeyValuePair <string, string>("disablesmilies", "0"),
                new KeyValuePair <string, string>("savecopy", "1"),
                new KeyValuePair <string, string>("pmid", ""),
                new KeyValuePair <string, string>("ajax", ""),
                new KeyValuePair <string, string>("forward", ""),
                new KeyValuePair <string, string>("csrftoken", token)
            };

            var postContent = new FlashbackStringUrlContent(postData);

            var response = await _httpClient.PostAsync("https://www.flashback.org/private.php", postContent);

            return(response.IsSuccessStatusCode);
        }
Beispiel #2
0
        public async Task <bool> PostReply(string message, string threadId, string postId, string userId, string subsciptionType)
        {
            var postData = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("message", message),
                new KeyValuePair <string, string>("s", ""),
                new KeyValuePair <string, string>("do", "postreply"),
                new KeyValuePair <string, string>("t", threadId),
                new KeyValuePair <string, string>("p", postId),
                new KeyValuePair <string, string>("posthash", ""),
                new KeyValuePair <string, string>("poststarttime", ""),
                new KeyValuePair <string, string>("loggedinuser", userId),
                new KeyValuePair <string, string>("signature", "1"),
                new KeyValuePair <string, string>("parseurl", "1"),
                new KeyValuePair <string, string>("disablesmilies", "0"),
                new KeyValuePair <string, string>("emailupdate", subsciptionType),
                new KeyValuePair <string, string>("stoken", "")
            };

            var postContent = new FlashbackStringUrlContent(postData);

            var response = await _httpClient.PostAsync("https://www.flashback.org/newreply.php", postContent);

            return(response.IsSuccessStatusCode);
        }
Beispiel #3
0
        /// <summary>
        /// Loggar in
        /// </summary>
        /// <param name="username">Användarnamn</param>
        /// <param name="password">Lösenord</param>
        /// <returns></returns>
        public async Task <bool> TryLogin(string username, string password)
        {
            var postData = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("vb_login_username", username),
                new KeyValuePair <string, string>("vb_login_password", ""),
                new KeyValuePair <string, string>("do", "login"),
                new KeyValuePair <string, string>("cookieuser", "1"),
                new KeyValuePair <string, string>("vb_login_md5password", BuildMd5HashForLogin(password)),
                new KeyValuePair <string, string>("vb_login_md5password_utf", BuildMd5HashForLogin(password))
            };

            var postContent = new FlashbackStringUrlContent(postData);

            var response = await _httpClient.PostAsync("https://www.flashback.org/login.php", postContent);

            var pageUri = response.RequestMessage.RequestUri;

            var cookieContainer = new CookieContainer();
            IEnumerable <string> cookies;

            if (response.Headers.TryGetValues("set-cookie", out cookies))
            {
                foreach (var c in cookies)
                {
                    cookieContainer.SetCookies(pageUri, c);
                }
            }

            var loginCheck = cookieContainer.GetCookies(new Uri("https://flashback.org/"))
                             .Cast <Cookie>()
                             .FirstOrDefault(x => x.Name == "vbscanuserid");

            return(loginCheck != null);
        }
Beispiel #4
0
        /// <summary>
        /// Lägger till en tråd till favoriterna.
        /// </summary>
        /// <param name="forumThreadId">Id till tråden. Ska skickas in utan "t"</param>
        /// <returns>Om anropet gick bra eller ej</returns>
        public async Task <bool> AddThreadToFavourites(string forumThreadId)
        {
            var postData = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("do", "doaddsubscription"),
                new KeyValuePair <string, string>("threadid", forumThreadId),
                new KeyValuePair <string, string>("url", "https://www.flashback.org/t" + forumThreadId),
                new KeyValuePair <string, string>("folderid", "0"),     // todo: styr till vilken mapp, pressentera något? Eller bara skita i det som tidigare?
                new KeyValuePair <string, string>("emailupdate", "0")   // todo: läs ut användarens inställningar eller bara skita i det som tidigare?
            };

            var postContent = new FlashbackStringUrlContent(postData);

            var response = await _httpClient.PostAsync("https://www.flashback.org/subscription.php", postContent);

            return(response.IsSuccessStatusCode);
        }
Beispiel #5
0
        public async Task <bool> RemoveFavourite(FbFavourite favouriteItem)
        {
            var postData = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("s", ""),
                new KeyValuePair <string, string>("do", favouriteItem.Type == FbItemType.Forum ? "dostuff-forum" : "dostuff"),
                new KeyValuePair <string, string>("folderid", "0"),
                new KeyValuePair <string, string>(favouriteItem.FbId, "yes"),
                new KeyValuePair <string, string>("what", "delete"),
                new KeyValuePair <string, string>("stoken", "")
            };

            var postContent = new FlashbackStringUrlContent(postData);

            var response = await _httpClient.PostAsync("https://www.flashback.org/subscription.php", postContent);

            return(response.IsSuccessStatusCode);
        }
Beispiel #6
0
        public async Task <bool> DeleteMessage(string messageId, string folderId, string token)
        {
            var postData = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("do", "managepm"),
                new KeyValuePair <string, string>("csrftoken", token),
                new KeyValuePair <string, string>("s", ""),
                new KeyValuePair <string, string>("dowhat", "delete"),
                new KeyValuePair <string, string>("folderid", folderId),
                new KeyValuePair <string, string>("dowhat", "delete"),
                new KeyValuePair <string, string>("pm[" + messageId + "]", "true")
            };

            var postContent = new FlashbackStringUrlContent(postData);

            var response = await _httpClient.PostAsync("https://www.flashback.org/private.php", postContent);

            return(response.IsSuccessStatusCode);
        }