【问题标题】:How to Delete a Google Site by its id如何通过 ID 删除 Google 站点
【发布时间】:2013-12-08 05:07:20
【问题描述】:

我不知道如何根据 ID 删除 Google 网站。我想我需要为该站点创建SiteEntry 并调用delete() 方法,但不知道如何仅使用ID 创建SiteEntry

这就是我创建网站的方式:

SitesService client = new SitesService("domain-AppName-v1");
client.setUserCredentials("adminUSer@domain.com", "password");

//Define Site
SiteEntry entry = new SiteEntry();
entry.setTitle(new PlainTextConstruct("Accounting 001"));
entry.setSummary(new PlainTextConstruct("Accounting 001"));

entry.getCategories().add(new Category(TagCategory.Scheme.TAG, "Course Sessions", null));

//Create the site
SiteEntry result = client.insert(new URL("https://sites.google.com/feeds/site/domain.com/"), entry);

//This Delete does not work
result.delete();

//Trying to setup the id in a SiteEntry, it doesn't work either
SiteEntry e = new SiteEntry();
e.setId(result.getId());
e.delete();

【问题讨论】:

    标签: gdata-api google-sites google-data-api gdata-java-client


    【解决方案1】:

    原来这是一个愚蠢的问题。

    首先,https://developers.google.com/google-apps/sites/faq#DeleteSite 声明 API 尚不支持删除站点,必须通过网络面板手动删除它们。这真的很糟糕,因为我目前有数百个使用 API 创建的网站,手动删除它们很麻烦:-(

    其次,siteEntry.delete() 抛出一个异常,说“删除未实现”,所以在问题代码中添加它时我错了。

    最后,要检索 SiteEntry,您必须这样做:

    SitesService client = <initialize the service>
    SiteEntry site = client.getEntry(new URL(siteID), SiteEntry.class);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-20
      • 2019-07-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-19
      相关资源
      最近更新 更多