Exemplo n.º 1
0
        public static async Task <bool> PostShare(string postId)
        {
            TokenValidator.CheckTokenValidity();
            var client = new HttpClient();

            client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", Preferences.Get("token", string.Empty));
            var response = await client.GetAsync(sharepostUrl + postId);

            if (!response.IsSuccessStatusCode)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 2
0
        public static async Task <bool> PostComment(PostCommentReq req)
        {
            TokenValidator.CheckTokenValidity();
            var client  = new HttpClient();
            var json    = JsonConvert.SerializeObject(req);
            var content = new StringContent(json, Encoding.UTF8, "application/json");

            client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", Preferences.Get("token", string.Empty));
            var response = await client.PostAsync(createcommentUrl, content);

            if (!response.IsSuccessStatusCode)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 3
0
        public static async Task <List <GroupChats> > GetGroupChat(string groupId)
        {
            TokenValidator.CheckTokenValidity();
            try
            {
                HttpClient client = new HttpClient();
                client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", Preferences.Get("token", string.Empty));

                var response = await client.GetAsync(groupchatUrl + groupId);

                HttpContent httpContent = response.Content;
                var         json        = await httpContent.ReadAsStringAsync();

                var groups = JsonConvert.DeserializeObject <List <GroupChats> >(json);

                return(groups);
            }
            catch (Exception c)
            {
                Debug.WriteLine(c.Message);
            }
            return(null);
        }