java - Error while attempting to program page creation on google sites -
i'm trying programmatic-ally add pages google site using java. code:
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 @ " + 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 site hosted on google apps, domain (e.g. example.com) string sitename = "intratrial2"; return "https://sites.google.com/feeds/content/" + domain + "/" + sitename + "/"; } }
if comment out line syntax error following error report on running: exception in thread "main" com.google.gdata.util.serviceexception: internal server error internal error
i'm not sure i'm doing wrong here , i'd appreciate help. thanks.
Comments
Post a Comment