0

Web ページに特定の instagram ユーザーの画像を表示する必要があります。

Instagram API ドキュメントに記載されているように、ユーザーのフィードを「閲覧」できるようにするには、認証を受ける必要があります。

「アプリケーションがユーザーに代わってリクエストを行う場合 (コメント、いいね、ユーザーのフィードの閲覧など) にのみ認証が必要です。」( http://instagram.com/developer/authentication/ )

API ドキュメントに記載されているように、次の URL にリクエストを送信します。

https://instagram.com/oauth/authorize/?display=touch&client_id=[ClientID]
&redirect_uri=[callbackuri]/&response_type=token 

別の URL にリダイレクトされる: http://your_redirect_uri?code=CODEaccess_token (CODE) を取得して、instagram RESTful サービスを呼び出すことができます。

問題は、Web サイトの訪問者が Instagram にログインしていない場合、最初に認証するためにログイン ページに転送され、その後で初めてアクセス トークンを取得できることです。

私の質問は: コードビハインドからアプリケーションの instagram アカウントで (またはおそらく JavaScript で!) 自動的にログインして、このログイン ページをバイパスするにはどうすればよいですか?

ちなみに私はC#とInstasharp( http://instasharp.org/ )を使っています。

何か案は?

前もって感謝します!

4

1 に答える 1

0

最初に Instagram で開発者アプリを作成し、consumerkey と consumersecret を取得し、パスのコールバック URL を設定しますhttp://localhost:3104/Instagram.aspx

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);
    }

このページで自動リダイレクトし、このコードを呼び出します

   public void 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;

   }

トークンとユーザーIDを取得します

于 2015-03-17T12:51:26.243 に答える