Search code examples
c#asp.net-mvcinstagram-apisubscriptionsreal-time-updates

Instagram Real-time Photo Updates Subscriptions c#


I'm developing an asp mvc .net application and I'm trying to subscribe to Instagram Real-time updates. I've been searching and reading but I have not found and answer to my problem. My subscription code looks like:

                string accessToken = context.AccessToken;
            //Subscribing to Instagram real-time updates
            NameValueCollection parameters = new NameValueCollection();
            parameters.Add("client_id", myClientId);
            parameters.Add("client_secret", myClientSecret);
            parameters.Add("object", "user");
            parameters.Add("aspect", "media");
            parameters.Add("verify_token", context.AccessToken);
            parameters.Add("callback_url", @"https://xmovo.org/Instagram/Update");

            WebClient client = new WebClient();
            var responseAsync = client.UploadValuesTaskAsync(
                new Uri(@"https://api.instagram.com/v1/subscriptions/"),
                "POST",
                parameters);

            string response = System.Text.Encoding.ASCII.GetString(await responseAsync);

I defined a controller called "Instagram" and an action called "Update" that answer to GET and POST, but I'm getting this: "- Response: System.Net.WebException: The remote server returned an error: (400) Bad Request.". I would appreciate some help. Thanks!


Solution

  • Solved! callback_url can't be https. Now my application is working!