Ejemplo n.º 1
0
        private static bool marker_action(string access_token, string action, string type, List <string> entry_ids = null, List <string> feed_ids = null, List <string> category_ids = null, long?asOf = null)
        {
            string requestUrl = string.Format("{0}/v3/markers?ct={1}", Configuration.base_url, System.Web.HttpUtility.UrlEncode(Configuration.user_agent));
            Dictionary <string, string> headers = new Dictionary <string, string>();

            headers.Add("Authorization", string.Format("OAuth {0}", access_token));

            json_marker_action json = new json_marker_action();

            json.action   = action;
            json.type     = type;
            json.entryIds = entry_ids;
            json.feedIds  = feed_ids;

            JsonSerializerSettings settings = new JsonSerializerSettings();

            settings.NullValueHandling = NullValueHandling.Ignore;
            string jsonString = JsonConvert.SerializeObject(json, settings);

            Common.HTTPCommunications.Response response = Common.HTTPCommunications.SendPostRequestStringDataOnly(
                requestUrl,
                jsonString,
                headers,
                true);

            return(response.Success);
        }
Ejemplo n.º 2
0
        public static List <Entry> mget(string access_token, List <string> entry_ids, string continuation = null)
        {
            string requestUrl = string.Format("{0}/v3/entries/.mget?ct={1}", Configuration.base_url, System.Web.HttpUtility.UrlEncode(Configuration.user_agent));
            Dictionary <string, string> headers = new Dictionary <string, string>();

            headers.Add("Authorization", string.Format("OAuth {0}", access_token));

            json_parameters_mget_entries json = new json_parameters_mget_entries();

            json.ids          = entry_ids;
            json.continuation = continuation;

            JsonSerializerSettings settings = new JsonSerializerSettings();

            settings.NullValueHandling = NullValueHandling.Ignore;
            settings.Error            += delegate(object sender, Newtonsoft.Json.Serialization.ErrorEventArgs args)
            {
                throw args.ErrorContext.Error;
            };

            string jsonString = JsonConvert.SerializeObject(json, settings);

            Common.HTTPCommunications.Response response = Common.HTTPCommunications.SendPostRequestStringDataOnly(
                requestUrl,
                jsonString,
                headers,
                true);


            return(JsonConvert.DeserializeObject <List <Entry> >(response.Content, settings));
        }
Ejemplo n.º 3
0
        public static Authentication.token get_access_token_by_refresh_token(string refresh_token, string client_id, string client_secret, string grant_type)
        {
            string requestUrl = string.Format("{0}/v3/auth/token?ct={1}", Configuration.base_url, System.Web.HttpUtility.UrlEncode(Configuration.user_agent));
            Dictionary <string, string> headers = new Dictionary <string, string>();
            Dictionary <string, string> content = new Dictionary <string, string>();

            content.Add("refresh_token", System.Web.HttpUtility.UrlEncode(refresh_token));
            content.Add("client_id", System.Web.HttpUtility.UrlEncode(client_id));
            content.Add("client_secret", System.Web.HttpUtility.UrlEncode(client_secret));
            content.Add("grant_type", grant_type);


            JsonSerializerSettings settings = new JsonSerializerSettings();

            settings.NullValueHandling = NullValueHandling.Ignore;
            settings.Error            += delegate(object sender, Newtonsoft.Json.Serialization.ErrorEventArgs args)
            {
                throw args.ErrorContext.Error;
            };

            Common.HTTPCommunications.Response response = Common.HTTPCommunications.SendPostRequest(
                requestUrl,
                content,
                headers,
                true);

            return(JsonConvert.DeserializeObject <Model.Authentication.token>(response.Content, settings));
        }
Ejemplo n.º 4
0
        public list_of_unread_counts get_list_of_unread_counts(string access_token, bool?autorefresh = null)
        {
            string requestUrl = string.Format("{0}/v3/markers/counts?ct={1}", Configuration.base_url, System.Web.HttpUtility.UrlEncode(Configuration.user_agent));
            Dictionary <string, object> parameter = new Dictionary <string, object>();

            parameter.Add("autorefresh", autorefresh);
            string parameter_string = Common.GetParameter.get(parameter);

            if (!string.IsNullOrWhiteSpace(parameter_string))
            {
                requestUrl += "&" + parameter_string;
            }

            Dictionary <string, string> headers = new Dictionary <string, string>();

            headers.Add("Authorization", string.Format("OAuth {0}", access_token));

            Common.HTTPCommunications.Response response = Common.HTTPCommunications.SendGetRequest(
                requestUrl,
                headers);

            JsonSerializerSettings settings = new JsonSerializerSettings();

            settings.Error += delegate(object sender, Newtonsoft.Json.Serialization.ErrorEventArgs args)
            {
                throw args.ErrorContext.Error;
            };

            return(JsonConvert.DeserializeObject <list_of_unread_counts>(response.Content, settings));
        }
Ejemplo n.º 5
0
        public static entries_list get_entries_in_stream(string access_token, string stream_id, int?count = null, string ranked = null, bool?unread_only = null, long?newer_than = null, string continuation = null)
        {
            string requestUrl = string.Format("{0}/v3/streams/{1}/contents?ct={2}", Configuration.base_url, System.Web.HttpUtility.UrlEncode(stream_id), System.Web.HttpUtility.UrlEncode(Configuration.user_agent));
            Dictionary <string, object> parameter = new Dictionary <string, object>();

            parameter.Add("count", count);
            parameter.Add("ranked", ranked);
            parameter.Add("unreadOnly", unread_only);
            parameter.Add("newerThan", newer_than);
            parameter.Add("continuation", continuation);
            string parameter_string = Common.GetParameter.get(parameter);

            if (!string.IsNullOrWhiteSpace(parameter_string))
            {
                requestUrl += "&" + parameter_string;
            }

            Dictionary <string, string> headers = new Dictionary <string, string>();

            headers.Add("Authorization", string.Format("OAuth {0}", access_token));

            Common.HTTPCommunications.Response response = Common.HTTPCommunications.SendGetRequest(
                requestUrl,
                headers);

            JsonSerializerSettings settings = new JsonSerializerSettings();

            settings.Error += delegate(object sender, Newtonsoft.Json.Serialization.ErrorEventArgs args)
            {
                throw args.ErrorContext.Error;
            };

            return(JsonConvert.DeserializeObject <entries_list>(response.Content, settings));
        }
Ejemplo n.º 6
0
        public static bool update(string access_token, string id, string title, string sortid, List <Category> categories)
        {
            string requestUrl = string.Format("{0}/v3/subscriptions??ct={1}", Configuration.base_url, System.Web.HttpUtility.UrlEncode(Configuration.user_agent));
            Dictionary <string, string> headers = new Dictionary <string, string>();

            headers.Add("Authorization", string.Format("OAuth {0}", access_token));

            json_parameter_subscribe json = new json_parameter_subscribe();

            json.id         = id;
            json.title      = title;
            json.sortid     = sortid;
            json.categories = categories;

            JsonSerializerSettings settings = new JsonSerializerSettings();

            settings.NullValueHandling = NullValueHandling.Ignore;
            settings.Error            += delegate(object sender, Newtonsoft.Json.Serialization.ErrorEventArgs args)
            {
                throw args.ErrorContext.Error;
            };

            string jsonString = JsonConvert.SerializeObject(json, settings);

            Common.HTTPCommunications.Response response = Common.HTTPCommunications.SendPostRequestStringDataOnly(
                requestUrl,
                jsonString,
                headers,
                true);

            return(response.Success);
        }
Ejemplo n.º 7
0
        public static bool delete_multiple_from_entries(string access_token, List <string> entry_ids, List <string> tag_ids)
        {
            string requestUrl = string.Format("{0}/v3/tags/{1}/{2}?ct={3}", Configuration.base_url, System.Web.HttpUtility.UrlEncode(string.Join(",", tag_ids)), System.Web.HttpUtility.UrlEncode(string.Join(",", entry_ids)), System.Web.HttpUtility.UrlEncode(Configuration.user_agent));
            Dictionary <string, string> headers = new Dictionary <string, string>();

            headers.Add("Authorization", string.Format("OAuth {0}", access_token));

            Common.HTTPCommunications.Response response = Common.HTTPCommunications.SendDeleteRequest(
                requestUrl,
                headers
                );

            return(response.Success);
        }
Ejemplo n.º 8
0
        public static UserInfo info(string base_url, string access_token)
        {
            string requestUrl = string.Format("{0}/reader/user/info", base_url);
            Dictionary <string, string> headers = new Dictionary <string, string>();

            headers.Add("Authorization", string.Format("Bearer {0}", access_token));

            Common.HTTPCommunications.Response response = Common.HTTPCommunications.SendGetRequest(
                requestUrl,
                headers);

            JsonSerializerSettings settings = new JsonSerializerSettings();

            settings.Error += delegate(object sender, Newtonsoft.Json.Serialization.ErrorEventArgs args)
            {
                throw args.ErrorContext.Error;
            };

            return(JsonConvert.DeserializeObject <UserInfo>(response.Content, settings));
        }
Ejemplo n.º 9
0
        public static Entry get(string access_token, string entry_id)
        {
            string requestUrl = string.Format("{0}/v3/entries/{1}?ct={2}", Configuration.base_url, entry_id, System.Web.HttpUtility.UrlEncode(Configuration.user_agent));
            Dictionary <string, string> headers = new Dictionary <string, string>();

            headers.Add("Authorization", string.Format("OAuth {0}", access_token));

            Common.HTTPCommunications.Response response = Common.HTTPCommunications.SendGetRequest(
                requestUrl,
                headers);

            JsonSerializerSettings settings = new JsonSerializerSettings();

            settings.Error += delegate(object sender, Newtonsoft.Json.Serialization.ErrorEventArgs args)
            {
                throw args.ErrorContext.Error;
            };

            return(JsonConvert.DeserializeObject <Entry>(response.Content, settings));
        }
Ejemplo n.º 10
0
        public static Authentication.token get_access_token(string code, string client_id, string client_secret, string redirect_uri, string grant_type = "authorization_code")
        {
            json_parameters_get_access_token_by_code json = new json_parameters_get_access_token_by_code();

            json.code          = code;
            json.client_id     = client_id;
            json.client_secret = client_secret;
            json.redirect_uri  = redirect_uri;
            json.grant_type    = grant_type;

            string requestUrl = string.Format("{0}/v3/auth/token?ct={1}", Configuration.base_url, System.Web.HttpUtility.UrlEncode(Configuration.user_agent));
            Dictionary <string, string> headers = new Dictionary <string, string>();
            Dictionary <string, string> content = new Dictionary <string, string>();

            content.Add("code", System.Web.HttpUtility.UrlEncode(code));
            content.Add("client_id", client_id);
            content.Add("client_secret", System.Web.HttpUtility.UrlEncode(client_secret));
            content.Add("redirect_uri", redirect_uri);
            content.Add("grant_type", grant_type);


            Common.HTTPCommunications.Response response = Common.HTTPCommunications.SendPostRequest(
                requestUrl,
                content,
                headers,
                true);


            JsonSerializerSettings settings = new JsonSerializerSettings();

            settings.Error += delegate(object sender, Newtonsoft.Json.Serialization.ErrorEventArgs args)
            {
                throw args.ErrorContext.Error;
            };

            return(JsonConvert.DeserializeObject <Model.Authentication.token>(response.Content, settings));
        }
Ejemplo n.º 11
0
        public static List <Feed> mget(string access_token, List <string> feed_ids)
        {
            string requestUrl = string.Format("{0}/v3/feeds/.mget?ct={1}", Configuration.base_url, System.Web.HttpUtility.UrlEncode(Configuration.user_agent));
            Dictionary <string, string> headers = new Dictionary <string, string>();

            headers.Add("Authorization", string.Format("OAuth {0}", access_token));

            string jsonString = JsonConvert.SerializeObject(feed_ids);

            Common.HTTPCommunications.Response response = Common.HTTPCommunications.SendPostRequestStringDataOnly(
                requestUrl,
                jsonString,
                headers,
                true);

            JsonSerializerSettings settings = new JsonSerializerSettings();

            settings.Error += delegate(object sender, Newtonsoft.Json.Serialization.ErrorEventArgs args)
            {
                throw args.ErrorContext.Error;
            };

            return(JsonConvert.DeserializeObject <List <Feed> >(response.Content, settings));
        }
Ejemplo n.º 12
0
        public static bool add_multiple_to_entries(string access_token, List <string> entry_ids, List <string> tag_ids)
        {
            string requestUrl = string.Format("{0}/v3/tags/{1}?ct={2}", Configuration.base_url, System.Web.HttpUtility.UrlEncode(string.Join(",", tag_ids)), System.Web.HttpUtility.UrlEncode(Configuration.user_agent));
            Dictionary <string, string> headers = new Dictionary <string, string>();

            headers.Add("Authorization", string.Format("OAuth {0}", access_token));

            json_tagging json = new json_tagging();

            json.entryIds = entry_ids;

            JsonSerializerSettings settings = new JsonSerializerSettings();

            settings.NullValueHandling = NullValueHandling.Ignore;
            string jsonString = JsonConvert.SerializeObject(json, settings);

            Common.HTTPCommunications.Response response = Common.HTTPCommunications.SendPutRequestStringDataOnly(
                requestUrl,
                jsonString,
                headers,
                true);

            return(response.Success);
        }