Blogger ブログに投稿をアップロードしようとしていますが、エラーが発生します。私は Eclipse を使用しており、参照されるライブラリは google-oauth-java-client-1.17.0-rc および gdata-src.java-1.47.1 です。
コード:
import com.google.gdata.client.GoogleService;
import com.google.gdata.data.Entry;
import com.google.gdata.data.PlainTextConstruct;
import com.google.gdata.util.ServiceException;
import java.io.IOException;
import java.net.URL;
public class Blogger {
public static void createPost(GoogleService myService) throws ServiceException, IOException {
// Create the entry to insert
Entry myEntry = new Entry();
// POST Title
myEntry.setTitle(new PlainTextConstruct("INDIA DEFEATED PAKISTAN "));
// Post description
myEntry.setContent(new PlainTextConstruct("INDIA Defeated pakistan in only 4 seconds . Hindustan Jindabad "));
// Blogger URL
URL postUrl = new URL("http://www.myblogspotsite.com/");
myService.insert(postUrl, myEntry);
}
public static void main(String ar[]) throws ServiceException, IOException {
//creating Google service required to access and update Blogger post
GoogleService myService = new GoogleService("blogger", "exampleCo-exampleApp-1");
myService.setUserCredentials("MY_GMAIL", "MY_PASSWORD");
createPost(myService);
}
}
エラー:
Exception in thread "main" com.google.gdata.util.ServiceException: Method Not Allowed
<HTML>
<HEAD>
<TITLE>Method Not Allowed</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Method Not Allowed</H1>
<H2>Error 405</H2>
</BODY>
</HTML>
at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:632)
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 Blogger.createPost(Blogger.java:27)
at Blogger.main(Blogger.java:35)