private string GetAspect(RealTimeAspects aspect)
        {
            switch (aspect)
            {
            case RealTimeAspects.Media:
                return("media");

            default:
                return(null);
            }
        }
        /// <summary>
        /// Create RealTime Location Subscription.
        /// </summary>
        /// <param name="clientId"></param>
        /// <param name="clientSecret"></param>
        /// <param name="verifyToken"></param>
        /// <param name="callbackUrl"></param>
        /// <param name="objectId"></param>
        /// <param name="aspect">The aspect of the object you'd like to subscribe to.</param>
        /// <returns></returns>
        public async Task <string> CreateLocationSubscriptionAsync(string verifyToken, string callbackUrl, long objectId, RealTimeAspects aspect)
        {
            using (HttpClient httpClient = new HttpClient())
            {
                var postData = BuildFormUrlEncodedContentData(this.clientId, this.clientSecret, "location", verifyToken, callbackUrl, aspect);
                postData.Add(new KeyValuePair <string, string>("object_id", objectId.ToString()));
                FormUrlEncodedContent content = new FormUrlEncodedContent(postData);
                var response = await httpClient.PostAsync(InstagramAPIUrls.RealTimeSubscriptionsUrl, content);

                string responseContent = await response.Content.ReadAsStringAsync();

                if (response.IsSuccessStatusCode)
                {
                    return(responseContent);
                }
                else
                {
                    throw new InstagramAPIException(responseContent);
                }
            }
        }
        /// <summary>
        /// Create RealTime User Subscription.
        /// </summary>
        /// <param name="clientId"></param>
        /// <param name="clientSecret"></param>
        /// <param name="verifyToken"></param>
        /// <param name="callbackUrl"></param>
        /// <param name="aspect">The aspect of the object you'd like to subscribe to.</param>
        /// <returns></returns>
        public async Task <HttpResponseMessage> CreateUserSubscriptionAsync(string verifyToken, string callbackUrl, RealTimeAspects aspect)
        {
            using (HttpClient httpClient = new HttpClient())
            {
                var postData = BuildFormUrlEncodedContentData(this.clientId, this.clientSecret, "user", verifyToken, callbackUrl, aspect);
                FormUrlEncodedContent content = new FormUrlEncodedContent(postData);
                var response = await httpClient.PostAsync(InstagramAPIUrls.RealTimeSubscriptionsUrl, content);

                return(response);
            }
        }
        private List <KeyValuePair <string, string> > BuildFormUrlEncodedContentData(string clientId, string clientSecret, string obj, string verifyToken, string callbackUrl, RealTimeAspects aspect)
        {
            var postData = new List <KeyValuePair <string, string> >();

            postData.Add(new KeyValuePair <string, string>("client_id", clientId));
            postData.Add(new KeyValuePair <string, string>("client_secret", clientSecret));
            postData.Add(new KeyValuePair <string, string>("verify_token", verifyToken));
            postData.Add(new KeyValuePair <string, string>("callback_url", callbackUrl));
            postData.Add(new KeyValuePair <string, string>("object", obj));
            postData.Add(new KeyValuePair <string, string>("aspect", GetAspect(aspect)));
            return(postData);
        }
        /// <summary>
        /// Create Geography User Subscription.
        /// Note:
        /// To create a subscription to a geography, specify a center latitude and longitude and a radius of the area you'd like to capture around that point (maximum radius is 5000 meters)
        /// </summary>
        /// <param name="clientId"></param>
        /// <param name="clientSecret"></param>
        /// <param name="verifyToken"></param>
        /// <param name="callbackUrl"></param>
        /// <param name="lat">Latitude.</param>
        /// <param name="lng">Longitude.</param>
        /// <param name="radius">Maximum radius is 5000 meters</param>
        /// <param name="aspect">The aspect of the object you'd like to subscribe to.</param>
        /// <returns></returns>
        public async Task <string> CreateGeographySubscriptionAsync(string verifyToken, string callbackUrl, double lat, double lng, double radius, RealTimeAspects aspect)
        {
            using (HttpClient httpClient = new HttpClient())
            {
                var postData = BuildFormUrlEncodedContentData(this.clientId, this.clientSecret, "geography", verifyToken, callbackUrl, aspect);
                postData.Add(new KeyValuePair <string, string>("lat", lat.ToString()));
                postData.Add(new KeyValuePair <string, string>("lng", lng.ToString()));
                postData.Add(new KeyValuePair <string, string>("radius", radius.ToString()));
                FormUrlEncodedContent content = new FormUrlEncodedContent(postData);
                var response = await httpClient.PostAsync(InstagramAPIUrls.RealTimeSubscriptionsUrl, content);

                string responseContent = await response.Content.ReadAsStringAsync();

                if (response.IsSuccessStatusCode)
                {
                    return(responseContent);
                }
                else
                {
                    throw new InstagramAPIException(responseContent);
                }
            }
        }
        /// <summary>
        /// Create RealTime User Subscription.
        /// </summary>
        /// <param name="clientId"></param>
        /// <param name="clientSecret"></param>
        /// <param name="verifyToken"></param>
        /// <param name="callbackUrl"></param>
        /// <param name="aspect">The aspect of the object you'd like to subscribe to.</param>
        /// <returns></returns>
        public async Task <string> CreateUserSubscriptionAsync(string verifyToken, string callbackUrl, RealTimeAspects aspect)
        {
            using (HttpClient httpClient = new HttpClient())
            {
                var postData = BuildFormUrlEncodedContentData(this.clientId, this.clientSecret, "user", verifyToken, callbackUrl, aspect);
                FormUrlEncodedContent content = new FormUrlEncodedContent(postData);
                var response = await httpClient.PostAsync(InstagramAPIUrls.RealTimeSubscriptionsUrl, content);

                string responseContent = await response.Content.ReadAsStringAsync();

                if (response.IsSuccessStatusCode)
                {
                    return(responseContent);
                }
                else
                {
                    throw new InstagramAPIException(responseContent);
                }
            }
        }