Calendar 向google日历添加条目时出现ServiceBanbidded异常

Calendar 向google日历添加条目时出现ServiceBanbidded异常,calendar,google-api,google-calendar-api,google-api-client,android-calendar,Calendar,Google Api,Google Calendar Api,Google Api Client,Android Calendar,我试图在谷歌日历中添加一个条目,但得到服务禁止例外。这是一个包含标题、内容和日期范围的简单条目。下面提供的代码片段 public void temp() { URL postURL = null; try { postURL = new URL("http://www.google.com/calendar/feeds/MAILID@gmail.com/PASSWORD/full"); EventEntry eventEntry = new EventEntry(); e

我试图在谷歌日历中添加一个条目,但得到服务禁止例外。这是一个包含标题、内容和日期范围的简单条目。下面提供的代码片段

public void temp() {
URL postURL = null;
try {
    postURL = new URL("http://www.google.com/calendar/feeds/MAILID@gmail.com/PASSWORD/full");
    EventEntry eventEntry = new EventEntry();
    eventEntry.setTitle(new PlainTextConstruct("One"));
    eventEntry.setContent(new PlainTextConstruct("Two"));

    When eventTime = new When();
    eventTime.setStartTime(DateTime.parseDateTime("2016-03-09T15:00:00-08:00"));
    eventTime.setEndTime(DateTime.parseDateTime("2016-03-09T15:00:00-08:00"));
    eventEntry.addTime(eventTime);

    CalendarService calendarService = new CalendarService("Savor");
    EventEntry createdEvent = calendarService.insert(postURL, eventEntry);
} catch (Exception e) {
    e.printStackTrace();
}
}

在执行此操作时,我得到了下面提供的ServiceForbidden异常[请忽略异常中显示的行号]

    com.google.gdata.util.ServiceForbiddenException: Forbidden
<HTML>
<HEAD>
<TITLE>Forbidden</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Forbidden</H1>
<H2>Error 403</H2>
</BODY>
</HTML>

    at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:605)
    at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:564)
    at com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:560)
    at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:538)
    at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:536)
    at com.google.gdata.client.Service.insert(Service.java:1409)
    at com.google.gdata.client.GoogleService.insert(GoogleService.java:613)
    at GCalender.temp(GCalender.java:68)
    at GCalender.main(GCalender.java:85)
com.google.gdata.util.ServiceBankeddenException:禁止
被禁止的
被禁止的
错误403
位于com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:605)
位于com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:564)
位于com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:560)
位于com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:538)
位于com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:536)
位于com.google.gdata.client.Service.insert(Service.java:1409)
位于com.google.gdata.client.GoogleService.insert(GoogleService.java:613)
在GCalender.temp下(GCalender.java:68)
位于GCalender.main(GCalender.java:85)
此行发生异常:EventEntry createdEvent=calendarService.insert(postrl,EventEntry)

试图解决这个问题,但在这一点上有点结巴。如果有人已经遇到了这个问题,请提供您的意见,这将是一个很大的帮助

谢谢


附言:请。如果问题标记了不正确的标记项,则忽略此问题。

您使用的是Google Calendar API v2,需要切换到它

文件

更新:

您的代码包含以下内容

MAILID@gmail.com/PASSWORD/

您还需要注意,使用登录名和密码访问Google API不再有效。客户端登录也被关闭。您需要使用Oauth2对您的应用程序进行身份验证。

在您请求或尝试让它工作之前?我不明白这个??MAILID@gmail.com/密码/感谢您的回复!!!!这就是crct,天真的问题:我对oauth/oauth2非常陌生。Hv通过链接,我必须为每个需要标记日历条目的新用户gmail ID生成JSON?我将在我的应用程序中设计一个简单的用户界面来获取邮件ID/pwd。但是如何生成这个过程需要的JSON?!如果可能的话,你能提供更多的想法吗??!?。我占用了你太多的时间:-(
MAILID@gmail.com/PASSWORD/