java 获取Google Maps Data API 服务

yuzhibofei123 2013-06-08 04:54:41
import com.google.gdata.client.*;
import com.google.gdata.client.maps.*;
import com.google.gdata.data.*;
import com.google.gdata.data.maps.*;
import com.google.gdata.util.*;
import java.io.IOException;
import java.net.URL;

public class GetMapsFeel
{
public static void main(String[] args){
MapsService myService = new MapsService("applicationName");
try{
myService.setUserCredentials("username","password");
}catch(AuthenticationException e){
e.printStackTrace();
}
try{
printUserMaps(myService);
}catch(ServiceException e){
e.printStackTrace();
}catch(IOException e){
e.printStackTrace();
}
}
public static void printUserMaps(MapsService myService) throws ServiceException,IOException {
final URL feedUrl=new URL("http://maps.google.com/maps/feeds/maps/default/full");
MapFeed resultFeed = myService.getFeed(feedUrl,MapFeed.class);
System.out.println(resultFeed.getTitle().getPlainText());
for(int i=0;i<resultFeed.getEntries().size();i++){
MapEntry entry=resultFeed.getEntries().get(i);
System.out.println(entry.getTitle().getPlainText());
System.out.println("Summary"+entry.getSummary().getPlainText());
System.out.println("Self Link:"+entry.getSelfLink().getHref()+"\n");
}

}
}
运行时报com.google.gdata.util.AuthenticationException: Error connecting with login URI,是applicationName,username和password的原因,这个我不会写,
...全文
81 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复

51,410

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧