2 messages in com.googlegroups.bloggerdevRe: Updating or Inserting an Entry us...| From | Sent On | Attachments |
|---|---|---|
| sl | 05 Jan 2007 11:49 | |
| hseo...@gmail.com | 13 Feb 2007 18:50 |
| Subject: | Re: Updating or Inserting an Entry using server side code![]() |
|---|---|
| From: | hseo...@gmail.com (hseo...@gmail.com) |
| Date: | 02/13/2007 06:50:51 PM |
| List: | com.googlegroups.bloggerdev |
Are you still having this problem? The same thing is happening to me. Thanks Hernan
On Jan 5, 4:50 pm, "sl" <shuk...@hotmail.com> wrote:
Please help, Is it possible to use server side code to authenticate and then update/ insert or delete an existing blog entry using the java client API running on the server side? If so, can anyone please provide an example?
It seems that I can read entries with no problems, but I am getting an authentication error when I try to update [see below]. Is there any way to use a token (like in the case of Google Base API) instead of the AuthSub system that requires an operator/ user to enter their data?
Thank you,
Shuki
// try to read a post: URL feedUrl = new URL("http://<my blog>.blogspot.com/feeds/posts/default"); GoogleService myService = new GoogleService("blogger", "<my app>App-1");
// Set up authentication (optional for beta Blogger, required for current Blogger): myService.setUserCredentials("<my gmail account>", "<password to new blogger>");
// Send the request and receive the response: Feed myFeed = myService.getFeed(feedUrl, Feed.class);
// Print the title of the returned feed: System.out.println(myFeed.getTitle().getPlainText());
List<Entry> list = myFeed.getEntries(); for(Entry entry : list){ String plainText = entry.getTitle().getPlainText(); System.out.println(plainText); entry.setTitle(new PlainTextConstruct(plainText+ " Updated:"+new Date(System.currentTimeMillis())));
List<Link> links = entry.getLinks(); for(Link link : links){ if(link.getRel().equalsIgnoreCase("self")){ myService.update(new URL(link.getHref()), entry); } } }
The error shows: java.lang.NullPointerException: No authentication header information at com.google.gdata.util.AuthenticationException.initFromAuthHeader(Unknown Source) at com.google.gdata.util.AuthenticationException.<init>(Unknown Source) at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(Unknown Source) at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(Unknown Source) at com.google.gdata.client.http.HttpGDataRequest.checkResponse(Unknown Source) at com.google.gdata.client.http.HttpGDataRequest.execute(Unknown Source) at com.google.gdata.client.http.GoogleGDataRequest.execute(Unknown Source) at com.google.gdata.client.Service.update(Unknown Source) at com.google.gdata.client.GoogleService.update(Unknown Source) at google.com.gumiyo.google.blogger.BloggerPostTest.testRead(BloggerPostTest.java:46) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)




