예제 #1
0
        public string UnMute(string id)
        {
            Console.WriteLine("UnMute user : "******"POST", "https://api.twitter.com/1.1/mutes/users/destroy.json", obj);
                req.GetRequestStream().Write(buff, 0, buff.Length);
                Stream resStream = req.GetResponse().GetResponseStream();
                if (resStream == null)
                {
                    return(string.Empty);
                }
                using (StreamReader reader = new StreamReader(resStream))
                {
                    UserInfoObject result = JsonConvert.DeserializeObject <UserInfoObject>(reader.ReadToEnd());
                    return(result.id_str);
                }
            }
            catch (WebException ex)
            {
                Stream resStream = ex.Response?.GetResponseStream();
                if (resStream == null)
                {
                    return(string.Empty);
                }
                using (StreamReader reader = new StreamReader(resStream))
                {
                    string response = reader.ReadToEnd();
                    Console.WriteLine(response);

                    if (Regex.IsMatch(response, @"(?i)""code""\s*:\s*88"))
                    {
                        throw new RateLimitException {
                                  target = id
                        }
                    }
                    ;
                }
            }

            return(string.Empty);
        }
    }
예제 #2
0
        public string UnBlock(string id, bool isScreenName = false)
        {
            Console.WriteLine("UnBlock user : "******"POST", "https://api.twitter.com/1.1/blocks/destroy.json", obj);
                req.GetRequestStream().Write(buff, 0, buff.Length);
                Stream resStream = req.GetResponse().GetResponseStream();
                if (resStream == null)
                {
                    return(string.Empty);
                }
                using (StreamReader reader = new StreamReader(resStream))
                {
                    UserInfoObject result = JsonConvert.DeserializeObject <UserInfoObject>(reader.ReadToEnd());
                    return(result.id_str);
                }
            }
            catch (WebException ex)
            {
                Stream resStream = ex.Response?.GetResponseStream();
                if (resStream == null)
                {
                    return(string.Empty);
                }
                using (StreamReader reader = new StreamReader(resStream))
                    Console.WriteLine(reader.ReadToEnd());
            }

            return(string.Empty);
        }