-1
我可以通過AccountManager獲得一個訪問令牌,但是下一步我應該怎麼做才能連接到人們的API?通過AccountManager連接到人們的api帳戶android
我可以通過AccountManager獲得一個訪問令牌,但是下一步我應該怎麼做才能連接到人們的API?通過AccountManager連接到人們的api帳戶android
都好,如果我有我的令牌可以訪問任何谷歌的API, 令牌=字符串 `
HttpTransport HTTP_TRANSPORT = new NetHttpTransport();
JacksonFactory JSON_FACTORY = new JacksonFactory();
try {
GoogleCredential credential = new GoogleCredential().setAccessToken(token);
PeopleService service=new PeopleService.Builder(HTTP_TRANSPORT,
JSON_FACTORY, credential).build();
ListConnectionsResponse response = service.people().connections()
.list("people/me")
.setPageSize(10)
.setPersonFields("names, emailAddresses")
.execute();
List<Person> connections = response.getConnections();
for(int i=0;i<response.size();i++)
for(int j=0;j<connections.size();j++)
System.out.println(connections.get(j));
`