public class GoogleReader {
private static final String
_AUTHPARAMS = "GoogleLogin auth=";
private static final String
_GOOGLE_LOGIN_URL = "https://www.google.com/accounts/ClientLogin";
private static final String _READER_BASE_URL = "http://www.google.com/reader/";
private static final String _API_URL = _READER_BASE_URL + "api/0/";
private static final String _UNREAD_COUNT_URL = _API_URL +
"unread-count?output=json";
public static String getGoogleUnreadCount(String _USERNAME, String
_PASSWORD) throws UnsupportedEncodingException, IOException {
String _RESULT = getUnreadCount(_USERNAME, _PASSWORD);
return
_RESULT;
}
public static String getUnreadCount(String
_USERNAME, String _PASSWORD) throws UnsupportedEncodingException, IOException {
Document doc = Jsoup.connect(_UNREAD_COUNT_URL)
.header("Authorization", _AUTHPARAMS +
getGoogleAuthKey(_USERNAME,_PASSWORD))
.userAgent("<your app
name>")
.timeout(4000)
.get();
String _RESULT = (String)doc.body().text();
return _RESULT;
}
public static String
getGoogleAuthKey(String _USERNAME, String _PASSWORD) throws
UnsupportedEncodingException, IOException {
Document doc =
Jsoup.connect(_GOOGLE_LOGIN_URL)
.data("accountType", "GOOGLE",
"Email", _USERNAME,
"Passwd", _PASSWORD,
"service",
"reader",
"source", "<your app name>")
.userAgent("<your app name>")
.timeout(4000)
.post();
String _AUTHKEY =
doc.body().text().substring(doc.body().text().indexOf("Auth="),
doc.body().text().length());
_AUTHKEY = _AUTHKEY.replace(
"Auth=","" );
return _AUTHKEY;
}
}
여기서,
String aa = getGoogleAuthKey("아이디", "비밀번호"); 로 실행하면 위에 빨간색 글씨로 표시한 connect(url) 부분에서 정지가 되는데요. 왜 그런지 이유를 도통 알수가없네요 ㅠㅠ..
분명히 실행이 되었는데 왜 안대는지 이유를 모르겠습니다..
jsoup 라이브러리 추가, 구글 라이브러리 추가했고요 다른 액티비티에서 저 클래스를 호출해서 쓰는구조입니다
답변해주시면 정말 감사하겠습니다..