在我的应用程序中,我的要求是获取用户照片并在我的应用程序中显示。
为此,我进行了身份验证,获得了访问令牌并输入了用户名密码,但这表明您无权打开此页面。接下来如何获取用户资料和照片。
这里我的代码是:
String url ="https://instagram.com/oauth/authorize?" +"response_type=token" +
"&redirect_uri=" + CALLBACK_URL+"&scope=basic"+"&client_id=" + CLIENT_ID ;
WebView webview = (WebView)findViewById(R.id.webview);
webview.setWebViewClient(new WebViewClient() {
public void onPageStarted(WebView view, String url, Bitmap favicon) {
String fragment = "#access_token=";
int start = url.indexOf(fragment);
if (start > -1) {
// You can use the accessToken for api calls now.
String accessToken = url.substring(start + fragment.length(), url.length());
Log.v(TAG, "OAuth complete, token: [" + accessToken + "].");
Log.i(TAG, "" +accessToken);
Toast.makeText(ActivityWebView.this, "Token: " + accessToken, Toast.LENGTH_SHORT).show();
}
}
});
webview.loadUrl(url);
}