Instagram访问令牌Windows应用商店应用C#

时间:2015-02-01 17:48:31

标签: c# windows-store-apps windows-store instagram-api

我想从windows app app中的instagram api获取访问令牌

这是我的代码:

string endURL = "ms-app://..";  string clientID = "..";
Uri endUri = new Uri(endURL);
string startURL = "https://api.instagram.com/oauth/authorize/?"
                + "client_id=" + clientID
                + "&redirect_uri=" + endURL
                + "&response_type=code";
try
{
    WebAuthenticationResult result = await WebAuthenticationBroker.AuthenticateAsync
        (WebAuthenticationOptions.None, startUri);
    if (result.ResponseStatus == WebAuthenticationStatus.Success) {
        string token = webAuthenticationResult.ResponseData;
}
catch(Exception) { }

我收到了这个错误:

  

指定的协议未知。 (HRESULT异常:0x800C000D)

1 个答案:

答案 0 :(得分:0)

为什么不直接使用InstaAPI github& codeplex


List<Scope> scopes = new List<Scope>() { Scope.basic };
InstaConfig config = new InstaConfig("CLIENT_ID", "CLIENT_SECRET", "REDIRECT_URI", scopes);

// use this to redirect user for authenticating your application
String AuthenticationUriString = config.GetAuthenticationUriString(); 

OAuth oauth = new OAuth(config, "CODE_ATTACHED_WITH_REDIRECTEDURI_AFTERSUCCESSFUL_AUTHENTICATION");
AuthUser user = oauth.GetAuhtorisedUser();

Console.WriteLine(user.AccessToken);