Пример #1
0
 public static redditAbout GetMe(redditLogin session)
 {
     redditAbout rAbbout = null;
     var request = new redditRequest
     {
         Method = "GET",
         Cookie = session.Data.Storage.cookie,
         User = session.UserHandle,
         Url = "http://www.reddit.com/api/me.json"
     };
     var json = string.Empty;
     if (request.Execute(out json) != HttpStatusCode.OK)
         throw new Exception(json);
     rAbbout = JsonConvert.DeserializeObject<redditAbout>(json);
     return rAbbout;
 }
Пример #2
0
 public static redditMessage Inbox(redditLogin session)
 {
     redditMessage msg = null;
     try
     {
         var request = new redditRequest
         {
             Method = "GET",
             Cookie = session.Data.Storage.cookie,
             User = session.UserHandle,
             Url = "http://www.reddit.com/message/inbox/.json"
         };
         var json = string.Empty;
         if (request.Execute(out json) != HttpStatusCode.OK)
             throw new Exception(json);
         msg = JsonConvert.DeserializeObject<redditMessage>(json);
     }
     catch
     {
         throw new Exception("Unable To Reach Inbox");
     }
     return msg;
 }
Пример #3
0
 public static bool HasMail(redditLogin session)
 {
     redditAbout a = GetMe(session);
     return a.data.has_mail;
 }
Пример #4
0
        public static string SendVote(string Full_ID, Vote vote, redditLogin session)
        {
            string buffer = string.Empty;
            try
            {
                var request = new redditRequest
                {
                    Method = "GET",
                    Cookie = session.Data.Storage.cookie,
                    User = session.UserHandle,
                    Url = "http://www.reddit.com/api/me.json"
                };
                var xml = string.Empty;
                if (request.Execute(out xml) != HttpStatusCode.OK)
                    throw new Exception(xml);
            }
            catch (Exception exp)
            {

            }
            return buffer;
        }
Пример #5
0
 public static redditMessageChild ReadMessage(redditLogin session, string id, redditMessage msg)
 {
     redditMessage mail = null;
     if (msg != null)
     {
         mail = msg;
     }
     else
     {
         mail = Inbox(session);
     }
     if (mail.data.children.Capacity > 0)
     {
         foreach (redditMessageChild child in mail.data.children)
         {
             if (child.data.id == id)
             {
                 return child;
             }
         }
     }
     return null;
 }
Пример #6
0
 public static void Logout(redditLogin login)
 {
     redditRequest request;
     string json = string.Empty;
     try
     {
         if (login.Data.Storage == null)
         {
             throw new Exception("Login Data Null");
         }
         if (String.IsNullOrEmpty(login.Data.Storage.modhash) || String.IsNullOrEmpty(login.Data.Storage.cookie))
         {
             throw new Exception("Login Data NULL");
         }
         request = new redditRequest
         {
             Url = "http://www.reddit.com/logout?uh=" + login.Data.Storage.modhash,
             Method = "POST",
             User = login.UserHandle,
             Cookie = login.Data.Storage.cookie,
             Content = "uh=" + login.Data.Storage.modhash + "&top=off"
         };
         if (request.Execute(out json) != HttpStatusCode.OK)
         {
             throw new Exception(json);
         }
     }
     catch (Exception exp)
     {
         throw exp;
     }
 }