public SocialQueryString GetQueryString() {
     SocialQueryString qs = new SocialQueryString();
     if (Count > 0) qs.Add("count", Count);
     if (!String.IsNullOrWhiteSpace(MinTagId)) qs.Add("min_tag_id", MinTagId);
     if (!String.IsNullOrWhiteSpace(MaxTagId)) qs.Add("max_tag_id", MaxTagId);
     return qs;
 }
 public SocialQueryString GetQueryString() {
     SocialQueryString qs = new SocialQueryString();
     if (UserId > 0) qs.Set("user_id", UserId);
     if (!String.IsNullOrWhiteSpace(ScreenName)) qs.Set("screen_name", ScreenName);
     if (Reverse) qs.Set("reverse", "1");
     return qs;
 }
 public virtual SocialQueryString GetQueryString() {
     SocialQueryString query = new SocialQueryString();
     if (Limit != null && Limit.Value >= 0) query.Set("limit", Limit.Value);
     if (Since > 0) query.Set("since", Since);
     if (Until > 0) query.Set("until", Until);
     return query;
 }
 public virtual SocialQueryString GetQueryString() {
     SocialQueryString query = new SocialQueryString();
     if (Limit != null && Limit.Value >= 0) query.Set("limit", Limit.Value);
     if (Before != null) query.Set("before", Before);
     if (After != null) query.Set("after", After);
     return query;
 }
 public SocialQueryString GetQueryString() {
     SocialQueryString query = new SocialQueryString();
     if (Count > 0) query.Add("count", Count);
     if (MinId != null) query.Add("min_id", MinId);
     if (MaxId != null) query.Add("max_id", MaxId);
     return query;
 }
 public SocialQueryString GetQueryString() {
     SocialQueryString query = new SocialQueryString();
     query.Set("id", Id);
     if (TrimUser) query.Add("trim_user", "true");
     if (IncludeMyRetweet) query.Add("include_my_retweet", "true");
     if (IncludeEntities) query.Add("include_entities", "true");
     return query;
 }
 public SocialQueryString GetQueryString() {
     SocialQueryString query = new SocialQueryString();
     if (Part != null) query.Add("part", Part.ToString());
     if (Ids != null && Ids.Length > 0) query.Add("id", String.Join(",", Ids));
     if (MaxResults > 0) query.Add("maxResults", MaxResults);
     if (!String.IsNullOrWhiteSpace(PageToken)) query.Add("pageToken", PageToken);
     return query;
 }
 public SocialQueryString GetQueryString() {
     SocialQueryString qs = new SocialQueryString();
     if (Id > 0) qs.Set("list_id", UserId);
     if (!String.IsNullOrWhiteSpace(Slug)) qs.Set("slug", Slug);
     if (UserId > 0) qs.Set("owner_id", UserId);
     if (!String.IsNullOrWhiteSpace(ScreenName)) qs.Set("owner_screen_name", ScreenName);
     return qs;
 }
 public SocialQueryString GetQueryString() {
     SocialQueryString qs = new SocialQueryString();
     if (UserId > 0) qs.Set("user_id", UserId);
     if (!String.IsNullOrWhiteSpace(ScreenName)) qs.Set("screen_name", ScreenName);
     if (Cursor != DefaultCursor) qs.Set("cursor", Cursor);
     if (Count != DefaultCount) qs.Set("count", Count);
     return qs;
 }
 public SocialQueryString GetQueryString() {
     SocialQueryString qs = new SocialQueryString();
     qs.Set("q", Query);
     if (Page > 1) qs.Set("page", Page);
     if (Count != 20) qs.Set("count", Count);
     if (!IncludeEntities) qs.Set("include_entities", "false");
     return qs;
 }
 public SocialQueryString GetQueryString() {
     SocialQueryString qs = new SocialQueryString();
     if (Count > 0) qs.Add("count", Count);
     if (MaxTimestamp != null) qs.Add("max_timestamp", SocialUtils.GetUnixTimeFromDateTime(MaxTimestamp.Value));
     if (MinTimestamp != null) qs.Add("min_timestamp", SocialUtils.GetUnixTimeFromDateTime(MinTimestamp.Value));
     if (MinId != null) qs.Add("min_id", MinId);
     if (MaxId != null) qs.Add("max_id", MaxId);
     return qs;
 }
 public SocialQueryString GetQueryString() {
     SocialQueryString qs = new SocialQueryString();
     if (UserId > 0) qs.Set("user_id", UserId);
     if (!String.IsNullOrWhiteSpace(ScreenName)) qs.Set("screen_name", ScreenName);
     if (Count > 0) qs.Set("count", Count);
     if (Cursor > 0) qs.Set("cursor", Cursor);
     if (FilterToOwnedLists) qs.Set("filter_to_owned_lists", "1");
     return qs;
 }
 public SocialQueryString GetQueryString() {
     SocialQueryString qs = new SocialQueryString();
     if (UserId > 0) qs.Set("user_id", UserId);
     if (!String.IsNullOrWhiteSpace(ScreenName)) qs.Set("screen_name", ScreenName);
     if (Count > 0) qs.Set("count", Count);
     if (SinceId > 0) qs.Set("since_id", SinceId);
     if (MaxId > 0) qs.Set("max_id", MaxId);
     if (!IncludeEntities) qs.Set("include_entities", "0");
     return qs;
 }
        /// <summary>
        /// Gets debug information about the specified access token.
        /// </summary>
        /// <param name="accessToken">The access token to debug.</param>
        /// <returns>The raw JSON response from the API.</returns>
        public SocialHttpResponse DebugToken(string accessToken) {

            // Declare the query string
            SocialQueryString query = new SocialQueryString();
            query.Add("input_token", accessToken);
            
            // Make the call to the API
            return Client.DoAuthenticatedGetRequest("/debug_token", query);
        
        }
        /// <summary>
        /// Search for tags by name. Results are ordered first as an exact match, then by popularity. Short tags will be treated as exact matches.
        /// </summary>
        /// <param name="tag">A valid tag name without a leading #. (eg. snowy, nofilter)</param>
        public SocialHttpResponse Search(string tag) {

            // Declare the query string
            SocialQueryString qs = new SocialQueryString();
            qs.Add("q", tag);

            // Perform the call to the API
            return Client.DoAuthenticatedGetRequest("https://api.instagram.com/v1/tags/search/", qs);

        }
 public SocialQueryString GetQueryString() {
     SocialQueryString qs = new SocialQueryString();
     if (UserId > 0) qs.Set("user_id", UserId);
     if (!String.IsNullOrWhiteSpace(ScreenName)) qs.Set("screen_name", ScreenName);
     if (Cursor != DefaultCursor) qs.Set("cursor", Cursor);
     if (Count != DefaultCount) qs.Set("count", Count);
     if (SkipStatus != DefaultSkipStatus) qs.Set("skip_status", SkipStatus ? "1" : "0");
     if (IncludeUserEntities != DefaultIncludeUserEntities) qs.Set("include_user_entities", IncludeUserEntities ? "1" : "0");
     return qs;
 }
        public SocialQueryString GetQueryString() {

            // Convert the collection of fields to a string
            string fields = (Fields == null ? "" : Fields.ToString()).Trim();

            // Construct the query string
            SocialQueryString query = new SocialQueryString();
            if (!String.IsNullOrWhiteSpace(fields)) query.Set("fields", fields);

            return query;

        }
 public SocialQueryString GetQueryString() {
     SocialQueryString qs = new SocialQueryString();
     if (Id > 0) qs.Set("list_id", UserId);
     if (!String.IsNullOrWhiteSpace(Slug)) qs.Set("slug", Slug);
     if (UserId > 0) qs.Set("owner_id", UserId);
     if (!String.IsNullOrWhiteSpace(ScreenName)) qs.Set("owner_screen_name", ScreenName);
     if (Count > 0) qs.Set("count", Count);
     if (Cursor > 0) qs.Set("cursor", Cursor);
     if (!IncludeEntities) qs.Set("include_entities", "0");
     if (SkipStatus) qs.Set("skip_status", "1");
     return qs;
 }
        public SocialQueryString GetQueryString() {

            // Declare the query string
            SocialQueryString qs = new SocialQueryString();
            qs.Add("lat", Latitude);
            qs.Add("lng", Longitude);

            // Optinal options
            if (Distance > 0) qs.Add("distance", Distance);
            if (MinTimestamp > 0) qs.Add("min_timestamp", MinTimestamp);
            if (MaxTimestamp > 0) qs.Add("max_timestamp", MaxTimestamp);

            return qs;

        }
        public SocialQueryString GetQueryString() {

            // Define the query string
            SocialQueryString qs = new SocialQueryString();

            // Add optional parameters
            if (SinceId > 0) qs.Add("since_id", SinceId);
            if (Count > 0) qs.Add("count", Count);
            if (MaxId > 0) qs.Add("max_id", MaxId);
            if (TrimUser) qs.Add("trim_user", "true");
            if (ExcludeReplies) qs.Add("exclude_replies", "true");
            if (ContributorDetails) qs.Add("contributor_details", "true");
            if (!IncludeRetweets) qs.Add("include_rts", "false");

            return qs;

        }
        public SocialQueryString GetQueryString() {

            // Initialize the query string
            SocialQueryString query = new SocialQueryString();

            // Set required parameters
            query.Set("lat", Latitude);
            query.Set("long", Longitude);

            // Set optional parameters
            if (Accurary != null && Accurary != "0m") query.Set("accuracy", Accurary);
            if (Granularity != default(TwitterGranularity)) query.Set("granularity", Granularity.ToString().ToLower());
            if (MaxResults > 0) query.Set("max_results", MaxResults);

            return query;

        }
示例#22
0
        /// <summary>
        /// Makes a GET request to the specified <code>url</code>.
        /// </summary>
        /// <param name="url">The URL of the request.</param>
        /// <param name="query">The query string of the request.</param>
        /// <returns>Returns an instance of <see cref="SocialHttpResponse"/> representing the response.</returns>
        public virtual SocialHttpResponse DoHttpGetRequest(string url, SocialQueryString query)
        {
            // Some input validation
            if (String.IsNullOrWhiteSpace(url))
            {
                throw new ArgumentNullException("url");
            }

            // Initialize the request
            SocialHttpRequest request = new SocialHttpRequest {
                Url         = url,
                QueryString = query
            };

            // Do something extra for the request
            PrepareHttpRequest(request);

            // Make the request to the specified URL
            return(request.GetResponse());
        }
示例#23
0
        /// <summary>
        /// Makes a POST request to the specified <code>url</code>.
        /// </summary>
        /// <param name="url">The URL of the request.</param>
        /// <param name="query">The query string of the request.</param>
        /// <param name="postData">The POST data of the request.</param>
        /// <param name="isMultipart">Indicates the request should be encoded as <code>multipart/form-data</code>.</param>
        /// <returns>Returns an instance of <see cref="SocialHttpResponse"/> representing the response.</returns>
        public virtual SocialHttpResponse DoHttpPostRequest(string url, SocialQueryString query, SocialPostData postData, bool isMultipart)
        {
            // Some input validation
            if (String.IsNullOrWhiteSpace(url))
            {
                throw new ArgumentNullException("url");
            }

            // Initialize the request
            SocialHttpRequest request = new SocialHttpRequest {
                Method      = SocialHttpMethod.Post,
                Url         = url,
                QueryString = query,
                PostData    = postData,
                IsMultipart = isMultipart
            };

            // Do something extra for the request
            PrepareHttpRequest(request);

            // Make the request to the specified URL
            return(request.GetResponse());
        }
 public SocialQueryString GetQueryString() {
     SocialQueryString qs = new SocialQueryString();
     if (Count > 0) qs.Add("count", Count);
     if (MaxLikeId != null) qs.Add("max_like_id", MaxLikeId);
     return qs;
 }
        /// <summary>
        /// Makes a POST request to the Facebook API. If the <code>AccessToken</code> property has
        /// been specified, the access token will be appended to the query string.
        /// </summary>
        /// <param name="url">The URL to call.</param>
        /// <param name="query">The query string of the request.</param>
        /// <param name="postData">The POST data.</param>
        /// <param name="isMultipart">If <code>true</code>, the content type of the request will be <code>multipart/form-data</code>, otherwise <code>application/x-www-form-urlencoded</code>.</param>
        /// <returns>Returns an instance of <code>SocialHttpResponse</code> wrapping the response from the Facebook Graph API.</returns>
        public SocialHttpResponse DoAuthenticatedPostRequest(string url, SocialQueryString query, SocialPostData postData, bool isMultipart) {

            // Throw an exception if the URL is empty
            if (String.IsNullOrWhiteSpace(url)) throw new ArgumentNullException("url");

            // Append the HTTP scheme and API version if not already specified.
            if (url.StartsWith("/")) {
                url = "https://graph.facebook.com" + (String.IsNullOrWhiteSpace(Version) ? "" : "/" + Version) + url;
            }

            // Initialize a new instance of SocialQueryString if the one specified is NULL
            if (query == null) query = new SocialQueryString();

            // Append the access token to the query string if present in the client and not already
            // specified in the query string
            if (!query.ContainsKey("access_token") && !String.IsNullOrWhiteSpace(AccessToken)) {
                query.Add("access_token", AccessToken);
            }

            // Append the query string to the URL
            if (!query.IsEmpty) url += (url.Contains("?") ? "&" : "?") + query;

            // Initialize a new HTTP request
            HttpWebRequest request = (HttpWebRequest) WebRequest.Create(url);

            // Set the HTTP method
            request.Method = "POST";

            // Write the POST data to the request stream
            if (postData != null && postData.Count > 0) {
                if (isMultipart) {
                    string boundary = Guid.NewGuid().ToString().Replace("-", "");
                    request.ContentType = "multipart/form-data; boundary=" + boundary;
                    using (Stream stream = request.GetRequestStream()) {
                        postData.WriteMultipartFormData(stream, boundary);
                    }
                } else {
                    string dataString = postData.ToString();
                    request.ContentType = "application/x-www-form-urlencoded";
                    request.ContentLength = dataString.Length;
                    using (Stream stream = request.GetRequestStream()) {
                        stream.Write(Encoding.UTF8.GetBytes(dataString), 0, dataString.Length);
                    }
                }
            }

            // Get the HTTP response
            try {
                return SocialHttpResponse.GetFromWebResponse(request.GetResponse() as HttpWebResponse);
            } catch (WebException ex) {
                if (ex.Status != WebExceptionStatus.ProtocolError) throw;
                return SocialHttpResponse.GetFromWebResponse(ex.Response as HttpWebResponse);
            }

        }
        /// <summary>
        /// Makes a GET request to the Facebook API. If the <code>AccessToken</code> property has
        /// been specified, the access token will be appended to the query string.
        /// </summary>
        /// <param name="url">The URL to call.</param>
        /// <param name="query">The query string of the request.</param>
        /// <returns>Returns an instance of <code>SocialHttpResponse</code> wrapping the response from the Facebook Graph API.</returns>
        public SocialHttpResponse DoAuthenticatedGetRequest(string url, SocialQueryString query) {

            // Throw an exception if the URL is empty
            if (String.IsNullOrWhiteSpace(url)) throw new ArgumentNullException("url");

            // Append the HTTP scheme and API version if not already specified.
            if (url.StartsWith("/")) {
                url = "https://graph.facebook.com" + (String.IsNullOrWhiteSpace(Version) ? "" : "/" + Version) + url;
            }

            // Initialize a new instance of SocialQueryString if the one specified is NULL
            if (query == null) query = new SocialQueryString();

            // Append the access token to the query string if present in the client and not already
            // specified in the query string
            if (!query.ContainsKey("access_token") && !String.IsNullOrWhiteSpace(AccessToken)) {
                query.Add("access_token", AccessToken);
            }

            // Append the locale to the query string if present in the client and not already
            // specified in the query string
            if (!query.ContainsKey("locale") && !String.IsNullOrWhiteSpace(Locale)) {
                query.Add("locale", Locale);
            }

            // Append the query string to the URL
            if (!query.IsEmpty) url += (url.Contains("?") ? "&" : "?") + query;

            // Initialize a new HTTP request
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

            // Get the HTTP response
            try {
                return SocialHttpResponse.GetFromWebResponse(request.GetResponse() as HttpWebResponse);
            } catch (WebException ex) {
                if (ex.Status != WebExceptionStatus.ProtocolError) throw;
                return SocialHttpResponse.GetFromWebResponse(ex.Response as HttpWebResponse);
            }

        }
        public SocialQueryString GetQueryString() {

            // Define the query string
            SocialQueryString qs = new SocialQueryString();

            // Add optional parameters
            if (UserId > 0) qs.Set("user_id", UserId);
            if (!String.IsNullOrWhiteSpace(ScreenName)) qs.Set("screen_name", ScreenName);
            if (SinceId > 0) qs.Set("since_id", SinceId);
            if (Count > 0) qs.Set("count", Count);
            if (MaxId > 0) qs.Set("max_id", MaxId);
            if (TrimUser) qs.Set("trim_user", "true");
            if (ExcludeReplies) qs.Set("exclude_replies", "true");
            if (ContributorDetails) qs.Set("contributor_details", "true");
            if (!IncludeRetweets) qs.Set("include_rts", "false");

            return qs;

        }
示例#28
0
        /// <summary>
        /// Makes a signed request to the Twitter API based on the specified parameters.
        /// </summary>
        /// <param name="method">The HTTP method of the request.</param>
        /// <param name="url">The base URL of the request (no query string).</param>
        /// <param name="queryString">The query string.</param>
        public virtual HttpWebResponse DoHttpRequest(string method, string url, SocialQueryString queryString) {

            // TODO: Should this method have is own implementation instead of calling another DoHttpRequest method?
        
            NameValueCollection query = queryString == null ? null : queryString.NameValueCollection;
            return DoHttpRequest(method, url, query, null);
        
        }
示例#29
0
 /// <summary>
 /// Makes a signed GET request to the specified <code>url</code>.
 /// </summary>
 /// <param name="url">The URL to call.</param>
 /// <param name="queryString">The query string.</param>
 public virtual SocialHttpResponse DoHttpGetRequest(string url, SocialQueryString queryString) {
     return SocialHttpResponse.GetFromWebResponse(DoHttpRequest("GET", url, queryString == null ? null : queryString.NameValueCollection, null));
 }
        /// <summary>
        /// Makes an authenticated GET request to the specified URL.
        /// </summary>
        /// <param name="url">The URL to call.</param>
        /// <param name="query">The query string for the call.</param>
        public SocialHttpResponse DoAuthenticatedGetRequest(string url, SocialQueryString query) {

            // Initialize a new SocialQueryString if NULL
            if (query == null) query = new SocialQueryString();
            
            // Configure the request
            SocialHttpRequest request = new SocialHttpRequest {
                Method = "GET",
                Url = url,
                QueryString = query
            };

            // Add an authorization header with the access token
            if (!query.ContainsKey("access_token") && !String.IsNullOrWhiteSpace(AccessToken)) {

                request.QueryString.Add("access_token", AccessToken);

                // Apparently not all methods support a bearer token (getting the pins of a board)
                //request.Headers.Authorization = "Bearer " + AccessToken;
            }

            // Set headers of the request

            // Make a call to the API
            return request.GetResponse();

        }
示例#31
0
        /// <summary>
        /// Makes an authenticated GET request to the specified URL. The access token is automatically appended to the query string.
        /// </summary>
        /// <param name="url">The URL to call.</param>
        /// <param name="query">The query string for the call.</param>
        public SocialHttpResponse DoAuthenticatedGetRequest(string url, SocialQueryString query) {

            // Initialize a new NameValueCollection if NULL
            if (query == null) query = new SocialQueryString();

            // Append the access token to the query string if present in the client and not already
            // specified in the query string
            if (!query.ContainsKey("token") && !String.IsNullOrWhiteSpace(AccessToken)) {
                query.Add("token", AccessToken);
            }

            // Configure the request
            SocialHttpRequest request = new SocialHttpRequest {
                Method = "GET",
                Url = url,
                QueryString = query,
                UserAgent = "Skybrud.Social"
            };

            // Make a call to the API
            return request.GetResponse();

        }
        /// <summary>
        /// Makes an authenticated GET request to the specified URL. If an access token has been
        /// specified for this client, that access token will be added to the query string.
        /// Similar if a client ID has been specified instead of an access token, that client ID
        /// will be added to the query string. However some endpoint methods may require an access
        /// token, and a client ID will therefore not be sufficient for such methods.
        /// </summary>
        /// <param name="url">The URL to call.</param>
        /// <param name="query">The query string for the call.</param>
        public SocialHttpResponse DoAuthenticatedGetRequest(string url, SocialQueryString query) {

            // Throw an exception if the URL is empty
            if (String.IsNullOrWhiteSpace(url)) throw new ArgumentNullException("url");

            // Initialize a new instance of SocialQueryString if the one specified is NULL
            if (query == null) query = new SocialQueryString();

            // Append either the access token or the client ID to the query string
            if (!String.IsNullOrWhiteSpace(AccessToken)) {
                query.Add("access_token", AccessToken);
            } else if (!String.IsNullOrWhiteSpace(ClientId)) {
                query.Add("client_id", ClientId);
            }

            // Append the query string to the URL
            if (!query.IsEmpty) url += (url.Contains("?") ? "&" : "?") + query;

            // Initialize a new HTTP request
            HttpWebRequest request = (HttpWebRequest) WebRequest.Create(url);

            // Get the HTTP response
            try {
                return SocialHttpResponse.GetFromWebResponse(request.GetResponse() as HttpWebResponse);
            } catch (WebException ex) {
                if (ex.Status != WebExceptionStatus.ProtocolError) throw;
                return SocialHttpResponse.GetFromWebResponse(ex.Response as HttpWebResponse);
            }

        }