Search code examples
c#asp.netinstagraminstagram-api

Post Image on Instagram with API using c#


I am building a Asp.net C# application i want to post the user uploaded picture directly to Instagram, but after a quick search i can not found any function in the API somebody help me how to post image on instagram wall by C# code

Below Code I can Get Access Token

    private void Authentication()
      {      
                string rest = string.Empty;
                GlobusInstagramLib.Authentication.ConfigurationIns config = new GlobusInstagramLib.Authentication.ConfigurationIns("https://instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["consumerKey"], ConfigurationManager.AppSettings["consumerSecret"], ConfigurationManager.AppSettings["callbackurl"], "https://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", "");
                oAuthInstagram _api = oAuthInstagram.GetInstance(config);
                rest = _api.AuthGetUrl("likes+comments+basic+relationships");
                Response.Redirect(rest); 
       }

// Call back Url

 public ActionResult Instagram()
    {
        string code = (String)Request.QueryString["code"];
        oAuthInstagram objInsta = new oAuthInstagram();
        GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["consumerKey"], ConfigurationManager.AppSettings["consumerSecret"], ConfigurationManager.AppSettings["callbackurl"], "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", "");
        oAuthInstagram _api = new oAuthInstagram();
        _api = oAuthInstagram.GetInstance(configi);
        AccessToken access = new AccessToken();
        access = _api.AuthGetAccessToken(code);
        string accessToken = access.access_token;
        string id =access.user.id;
        ViewBag.accessToken = accessToken;`enter code here`
        ViewBag.Uid = id;
        return View();     
    }

Below Code i have get Access Token and Profile ID How To Post Image ? some body tall me


Solution

  • You cannot upload photos to Instagram through the API. From Instagram's API documentation https://instagram.com/developer/endpoints/media/:

    At this time, uploading via the API is not possible. We made a conscious choice not to add this for the following reasons:

    • Instagram is about your life on the go – we hope to encourage photos from within the app.
    • We want to fight spam & low quality photos. Once we allow uploading from other sources, it's harder to control what comes into the Instagram ecosystem. All this being said, we're working on ways to ensure users have a consistent and high-quality experience on our platform.