Java 尝试在google站点上编程页面创建时出错

Java 尝试在google站点上编程页面创建时出错,java,Java,我正在尝试使用Java向我的Google站点添加页面。 代码如下: import java.io.*; import java.net.MalformedURLException; import java.net.URL; import com.google.gdata.client.sites.*; import com.google.gdata.data.PlainTextConstruct; import com.google.gdata.data.XhtmlTe

我正在尝试使用Java向我的Google站点添加页面。 代码如下:

    import java.io.*;
    import java.net.MalformedURLException;
    import java.net.URL;

import com.google.gdata.client.sites.*;
import com.google.gdata.data.PlainTextConstruct;
import com.google.gdata.data.XhtmlTextConstruct;
import com.google.gdata.data.sites.*;
import com.google.gdata.util.ServiceException;
import com.google.gdata.util.XmlBlob;


public class PageCreate {
public static void main(String args[]) throws Exception {
    WebPageEntry createdEntry = createWebPage("New Webpage Title", "<b>HTML content</b>");
    System.out.println("Created! View at " + createdEntry.getHtmlLink().getHref());
}
private static void setContentBlob(BaseContentEntry<?> entry, String pageContent) {
      XmlBlob xml = new XmlBlob();
      xml.setBlob(pageContent);
      entry.setContent(new XhtmlTextConstruct());
    }

    public static WebPageEntry createWebPage(String title, String content)
        throws ServiceException, IOException, MalformedURLException {
      SitesService client = new SitesService("*****-pagecreate-v1");
      client.setUserCredentials("***********", "*********");

      client.site = "intratrial2"; -> ***SYNTAX ERROR REPORTED***

      //ContentFeed contentFeed = client.getFeed(new URL(buildContentFeedUrl()), ContentFeed.class);
      WebPageEntry entry = new WebPageEntry();
      entry.setTitle(new PlainTextConstruct(title));

      setContentBlob(entry, content); // Entry's HTML content

      return client.insert(new URL(buildContentFeedUrl()), entry);
    }


      public static String buildContentFeedUrl() {
          String domain = "*****";  // OR if the Site is hosted on Google Apps, your domain (e.g. example.com)
          String siteName = "intratrial2";
          return "https://sites.google.com/feeds/content/" + domain + "/" + siteName + "/";
        }
}
import java.io.*;
导入java.net.MalformedURLException;
导入java.net.URL;
导入com.google.gdata.client.sites.*;
导入com.google.gdata.data.PlainTextConstruct;
导入com.google.gdata.data.XhtmlTextConstruct;
导入com.google.gdata.data.sites.*;
导入com.google.gdata.util.ServiceException;
导入com.google.gdata.util.XmlBlob;
公共类页面创建{
公共静态void main(字符串args[])引发异常{
WebPageEntry createdEntry=创建网页(“新网页标题”、“HTML内容”);
System.out.println(“在”+createdEntry.gethtmlink().getHref()处创建!视图”);
}
私有静态void setContentBlob(BaseContentEntry条目,字符串pageContent){
xmlblobxml=newxmlblob();
setBlob(pageContent);
setContent(新的XhtmlTextConstruct());
}
公共静态WebPageEntry createWebPage(字符串标题、字符串内容)
抛出ServiceException、IOException、MalformedUrlexException{
SitesService客户端=新SitesService(“******-pagecreate-v1”);
client.setUserCredentials(“**********”,“**********”);
client.site=“intratrial2”->***报告语法错误***
//ContentFeed ContentFeed=client.getFeed(新URL(buildContentFeedUrl()),ContentFeed.class);
WebPageEntry条目=新建WebPageEntry();
entry.setTitle(新的明文构造(title));
setContentBlob(条目,内容);//条目的HTML内容
返回client.insert(新URL(buildContentFeedUrl()),条目);
}
公共静态字符串buildContentFeedUrl(){
String domain=“****”;//或者如果站点托管在谷歌应用程序上,则为您的域(例如example.com)
字符串siteName=“intratrial2”;
返回“https://sites.google.com/feeds/content/“+domain+”/“+siteName+”/”;
}
}
如果我用语法错误注释掉该行,则在运行时会得到以下错误报告: 线程“main”com.google.gdata.util.ServiceException中出现异常:内部服务器错误 内部错误


我不确定我在这里做错了什么,我真的很感谢你的帮助。谢谢。

有趣的是,公共GDataAPI没有提到SiteService.client字段。你能为这个类添加到javadoc的链接吗?这就是问题所在。文档特别指示我在“创建内容”标题下声明“client.site=SiteName”{。但是就像你说的,gdataapi没有提到字段。所以我不确定他们要我做什么。嗯。。。这看起来像是不同版本的Javascript遗留下来的;您是否尝试查看程序发送的XML请求的网络跟踪,并将其与文档中显示的示例XML请求进行比较?