예제 #1
0
        public async Task <List <User> > getContacts()
        {
            List <User>        toReturn   = new List <User>();
            HttpRequestMessage webRequest = parentSkype.mainFactory.createWebRequest_GET("https://contacts.skype.com/contacts/v1/users/" + parentSkype.selfProfile.Username + "/contacts?$filter=type%20eq%20%27skype%27%20or%20type%20eq%20%27msn%27%20or%20type%20eq%20%27pstn%27%20or%20type%20eq%20%27agent%27&reason=default", new string[][] { new string[] { "X-Skypetoken", parentSkype.authTokens.SkypeToken } });
            string             rawInfo    = "";

            using (var handler = new HttpClientHandler()
            {
                CookieContainer = parentSkype.mainCookies
            })
                using (var client = new HttpClient(handler))
                {
                    client.DefaultRequestHeaders.Add("User-Agent", parentSkype.userAgent);
                    var result = await client.SendAsync(webRequest);

                    rawInfo = await result.Content.ReadAsStringAsync();
                }
            dynamic jsonObject = JsonConvert.DeserializeObject(rawInfo);

            foreach (dynamic singleUser in jsonObject.contacts)
            {
                toReturn.Add(userModule.userFromContacts(singleUser));
            }
            return(toReturn);
        }
예제 #2
0
        public User[] getContacts()
        {
            List <User>    toReturn   = new List <User>();
            HttpWebRequest webRequest = parentSkype.mainFactory.createWebRequest_GET("https://contacts.skype.com/contacts/v1/users/" + parentSkype.selfProfile.Username + "/contacts?$filter=type%20eq%20%27skype%27%20or%20type%20eq%20%27msn%27%20or%20type%20eq%20%27pstn%27%20or%20type%20eq%20%27agent%27&reason=default", new string[][] { new string[] { "X-Skypetoken", parentSkype.authTokens.SkypeToken } });
            string         rawInfo    = "";

            using (HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse())
            {
                rawInfo = new StreamReader(webResponse.GetResponseStream()).ReadToEnd();
            }
            dynamic jsonObject = JsonConvert.DeserializeObject(rawInfo);

            foreach (dynamic singleUser in jsonObject.contacts)
            {
                toReturn.Add(userModule.userFromContacts(singleUser));
            }
            return(toReturn.ToArray());
        }