//TODO требуется разрешить приложению доступ к данным
//https://oauth.vkontakte.ru/grant_access
if(response.getStatusLine().getStatusCode() == 200){
HeaderLocation = getGrantAccessURI(response.getEntity().getContent());
}else{
HeaderLocation = response.getFirstHeader("location").getValue();
}
httppost = new HttpPost(HeaderLocation);
response = httpclient.execute(httppost);
httppost.abort();
//http://api.vkontakte.ru/blank.html#code=9899346d792c1acdd2
HeaderLocation = response.getFirstHeader("location").getValue();
code = HeaderLocation.split("=")[1];
...
public static String getGrantAccessURI(InputStream inputStream) {
String url = null;
Scanner scanner = null;
try{
scanner = new Scanner(inputStream, "windows-1251");
StringBuilder sb = new StringBuilder();
while (scanner.hasNext()) {
sb.append(scanner.next());
}
url = findKey(sb.toString(),"location.href=\"" , "\"");
}
finally{
if(scanner != null)
scanner.close();
}
return url;
}
* This source code was highlighted with Source Code Highlighter.| Комментировать | « Пред. запись — К дневнику — След. запись » | Страницы: [1] [Новые] |