8.7.10

Java - Networking Properties

http://download.oracle.com/docs/cd/E17476_01/javase/1.4.2/docs/guide/net/properties.html

Java Properties
java.net.preferIPv4Stack (default: false)
If IPv6 is available on the operating system the underlying native socket will be an IPv6 socket. This allows Java(tm) applications to connect too, and accept connections from, both IPv4 and IPv6 hosts.

If an application has a preference to only use IPv4 sockets then this property can be set to true. The implication is that the application will not be able to communicate with IPv6 hosts.


java.net.preferIPv6Addresses (default: false)
If IPv6 is available on the operating system the default preference is to prefer an IPv4-mapped address over an IPv6 address. This is for backward compatibility reasons - for example applications that depend on access to an IPv4 only service or applications that depend on the %d.%d.%d.%d representation of an IP address. This property can be set to try to change the preferences to use IPv6 addresses over IPv4 addresses. This allows applications to be tested and deployed in environments where the application is expected to connect to IPv6 services.

networkaddress.cache.ttl (default: -1)
Specified in java.security to indicate the caching policy for successful name lookups from the name service.. The value is specified as as integer to indicate the number of seconds to cache the successful lookup.

A value of -1 indicates "cache forever".


networkaddress.cache.negative.ttl (default: 10)
Specified in java.security to indicate the caching policy for un-successful name lookups from the name service.. The value is specified as as integer to indicate the number of seconds to cache the failure for un-successful lookups.

A value of 0 indicates "never cache". A value of -1 indicates "cache forever".


http.proxyHost (default: <none>)
http.proxyPort (default: 80 if http.proxyHost specified)
http.nonProxyHosts (default: <none>

ftp.proxyHost (default: <none>)
ftp.proxyPort (default: 80 if ftp.proxyHost specified)
ftp.nonProxyHosts (default: <none>)

http.proxyHost and http.proxyPort indicate the proxy server and port that the http protocol handler will use.

http.nonProxyHosts indicates the hosts which should be connected too directly and not through the proxy server. The value can be a list of hosts, each seperated by a |, and in addition a wildcard character (*) can be used for matching. For example: -Dhttp.nonProxyHosts="*.foo.com|localhost".

ftp.proxyHost and ftp.proxyPort indicate the proxy server and port that the ftp protocol handler will use. ftp.nonProxyHosts is similiar to http.nonProxyHosts and indicates the hosts that should be connected too directly and not through the proxy server.


http.agent (default: Java1.4.0)
Indicates the User-Agent request header sent in http requests.

http.auth.digest.validateServer (default: false)
http.auth.digest.validateProxy (default: false)
http.auth.digest.cnonceRepeat (default: 5)
These system properties modify the behavior of the HTTP digest authentication mechanism. Digest authentication provides a limited ability for the server to authenticate itself to the client (ie. by proving that it knows the users password). However, not all servers support this capability and by default the check is switched off. The first two properties above can be set to true, to enforce this check, for either authentication with an origin, or a proxy server respectively.

It is not normally necessary to set the third property (http.auth.digest.cnonceRepeat). This determines how many times a cnonce value is reused. This can be useful when the MD5-sess algorithm is being used. Increasing the value reduces the computational overhead on both the client and the server by reducing the amount of material that has to be hashed for each HTTP request.


http.auth.ntlm.domain:
NTLM authentication is supported on Windows platforms only (due to licensing restrictions). Similar to other HTTP authentication schemes, NTLM uses the java.net.Authenticator class to acquire usernames and passwords when they are needed. However, NTLM also needs the NT domain name. There are three options for specifying the domain:
  1. Do not specify it. In some environments, the domain is not actually required and the application need not specify it.
  2. The domain name can be encoded within the username by prefixing the domain name followed by a back-slash '\' before the username. With this method, existing applications that use the Authenticator class do not need to be modified, so long as users are made aware that this notation must be used.
  3. If a domain name is not specified as in method 2) and the system property "http.auth.ntlm.domain" is defined, then the value of this property will be used as the domain name.

http.keepAlive (default: true)
Indicates if keep alive (persistent) connections should be supported. Persistent connections improve performance by allowing the underlying socket connection be reused for multiple http requests.

The default is true and thus persistent connections will be used with http 1.1 servers. Set to 'false' to disable the use of persistent connections.


http.maxConnections (default: 5)
If HTTP keep-alive is enabled, this value is the number of idle connections that will be simultaneously kept alive, per-destination.
SOCKS protocol support settings
The SOCKS username and password are acquired in the following way. First, if the application has registered a java.net.Authenticator default instance, then this will be queried with the protocol set to the string "SOCKS5", and the prompt set to to the string "SOCKS authentication". If the authenticator does not return a username/password or if no authenticator is registered then the system checks for the user preferences "java.net.socks.username" and "java.net.socks.password". If these preferences do not exist, then the system property "user.name" is checked for a username. In this case, no password is supplied.
socksProxyHost
socksProxyPort (default: 1080)
Indicates the name of the SOCKS proxy server and the port number that will be used by the SOCKS protocol layer. If socksProxyHost is specified then all TCP sockets will use the SOCKS proxy server to establish a connection or accept one. The SOCKS proxy server can either be a SOCKS v4 or v5 server and it has to allow for unauthenticated connections.
Sun implementation-specific properties
These properties may not be supported in future releases.
sun.net.inetaddr.ttl
This is a sun private system property which corresponds to networkaddress.cache.ttl. It takes the same value and has the same meaning, but can be set as a command-line option. However, the preferred way is to use the security property mentioned above.

sun.net.inetaddr.negative.ttl
This is a sun private system property which corresponds to networkaddress.cache.negative.ttl. It takes the same value and has the same meaning, but can be set as a command-line option. However, the preferred way is to use the security property mentioned above.

sun.net.client.defaultConnectTimeout (default: -1)
sun.net.client.defaultReadTimeout (default: -1)
These properties specify the default connect and read timeout (resp.) for the protocol handler used by java.net.URLConnection.

sun.net.client.defaultConnectTimeout specifies the timeout (in milliseconds) to establish the connection to the host. For example for http connections it is the timeout when establishing the connection to the http server. For ftp connection it is the timeout when establishing the connection to ftp servers.

sun.net.client.defaultReadTimeout specifies the timeout (in milliseconds) when reading from input stream when a connection is established to a resource.


JNDI DNS service provider settings
These properties may not be supported in future releases.
sun.net.spi.nameservice.provider.<n>=<default|dns,sun|...>
Specifies the name service provider that you can use. By default, Java will use the system configured name lookup mechanism, such as file, nis, etc. You can specify your own by setting this option. takes the value of a positive number, it indicates the precedence order with a small number takes higher precendence over a bigger number. In J2SETM 1.4, we have provided one DNS name service provider through JNDI, which is called "dns,sun".

sun.net.spi.nameservice.nameservers=<server1_ipaddr,server2_ipaddr ...>
You can specify a comma separated list of IP addresses that point to the DNS servers you want to use. If the sun.net.spi.nameservice.nameservers property is not defined, then the provider will use any name servers already configured in the platform DNS configuration.

sun.net.spi.nameservice.domain=<domainname>
This property specifies the default DNS domain name, for instance, eng.sun.com. If the sun.net.spi.nameservice.domain property is not defined then the provider will use any domain or domain search list configured in the platform DNS configuration.

Living Vicariously: Using Proxy Servers with the Google Data API Client Libraries

eff Fisher, Google Data APIs team
June 2007

Introduction: Why proxy?

A proxy server is a computer (or service on a computer) that makes requests for a number of client computers on their behalf, typically to external resources. This article is concerned with HTTP proxy servers as HTTP is the protocol used to access the public APIs for Google's web services. By extension, HTTPS or SSL proxies are also of interest when making HTTP requests that contain sensitive information such as private user data or passwords. Many large companies today use HTTP proxies to control what websites or information employees can view on the internet. Public libraries and schools have also been known to implement proxies for this purpose. There are also a number of publicly available proxy servers that can be used to anonymously access web content.

Potential issues faced when using a proxy server depend on what software is being used and how it is configured. A proxy is considered to be "transparent" if it does not alter the request from the client or the response from the server in any way other than is necessary for proxy identification and authentication. However, a large number of proxy servers do alter either the request or the response in ways that a developer should be aware of. In particular, certain proxies will alter the content-type of the response or strip out HTTP keep-alive headers from being sent to the outside server hosting the resource.

So why would a developer want to use an HTTP or SSL proxy? Generally, there are two reasons for this: it is required by some corporate infrastructure, or, the developer wishes to debug an application that uses a web service. The first reason is entirely unavoidable if the rules for the network the developer is working on prohibit non-proxied web or SSL connections to external websites. The latter reason is reported frequently in our support forums by developers trying to troubleshoot issues when dealing with a Google web service. There are special-purpose "debugging" proxies such as Fiddler and Charles that are geared towards this exact situation. For more information on this use of a proxy server, you may want to read our article On the Wire: Tools for API Developers.

For some applications, adding in proxy server support can be difficult. Fortunately, most of the client libraries for the Google Data API can be made to work with an HTTP proxy server after some slight code modifications. This article is intended to serve as a starting point for a developer who would like to use a proxy server for the web requests made by their application.

Java

Using an HTTP proxy with the Java client library is easy thanks to Sun's use of system properties to manage connection settings.

For example, if your corporate proxy server were running on "my.proxy.domain.com", on port 3128, you could add the following to your code before creating a service object for Google Calendar, Google Spreadsheets, etc.

System.setProperty("http.proxyHost", "my.proxy.domain.com");
System.setProperty("http.proxyPort", "3128");

Alternatively, this can be done on the command line when starting your servlet environment:

java -Dhttp.proxyHost=my.proxy.domain.com -Dhttp.proxyPort=3128

With more recent versions of the JSSE package, this can be extended to SSL proxies as well. If the same proxy server in the previous example was running an SSL proxy on port 3129, the necessary code would be:

System.setProperty("https.proxyHost", "my.proxy.domain.com");
System.setProperty("https.proxyPort", "3129");

This can also be done from the command line in the same fashion as with the HTTP proxy.

Sometimes, you might need to provide credentials to a proxy server in order to use it. Usually, they are submitted using a base64 hash included in an HTTP header, as follows:

String encoded = new String(Base64.encodeBase64(new String("username:password").getBytes()));
String base64encodedCredentials = "Basic " + encoded;
myService.getRequestFactory().setPrivateHeader("Proxy-Authorization", base64encodedCredentials);

Note that the above code uses the Apache Commons Codec package in order to do the base64 encoding necessary. You'll have to import theorg.apache.commons.codec.binary.Base64 class in order to run the above code.


.NET

To use an HTTP proxy with the .NET client library is not as trivial as with the Java client, but it can be accomplished in a similar way when creating the service object for a particular product.

For example, we might want to use a proxy to interact with the Google Calendar service:

using System.Net;

CalendarService service = new CalendarService("CalendarSampleApp");
query.Uri = new Uri(calendarURI);
GDataRequestFactory requestFactory = (GDataRequestFactory) service.RequestFactory;
IWebProxy iProxy = WebRequest.DefaultWebProxy;
WebProxy myProxy = new WebProxy(iProxy.GetProxy(query.Uri));
// potentially, setup credentials on the proxy here
myProxy.Credentials = CredentialCache.DefaultCredentials;
myProxy.UseDefaultCredentials = true;
requestFactory.Proxy = myProxy;

This should detect the necessary proxy from your Internet connection settings--a nice feature of the .NET library. However, if you do not trust it to discover the proxy properly, you can also set it by changing the code to:

using System.Net;

CalendarService service = new CalendarService("CalendarSampleApp");
GDataRequestFactory requestFactory = (GDataRequestFactory) service.RequestFactory;
WebProxy myProxy = new WebProxy("http://my.proxy.example.com:3128/",true);
// potentially, setup credentials on the proxy here
myProxy.Credentials = CredentialCache.DefaultCredentials;
myProxy.UseDefaultCredentials = true;
requestFactory.Proxy = myProxy;

Conclusion

This article has discussed how to have some of the Google Data API client libraries work with an HTTP proxy server. Developers working behind a proxy server mandated by network policy can still use these libraries. Developers can also employ a proxy server to help debug their code by having the proxy server record the contents of HTTP requests and responses being sent to and from a Google web service. There are more advanced use cases of a proxy server and other client libraries not covered by this tutorial. Developers needing additional help are encouraged to participate in our public support groups linked below.

For additional information on the client libraries used in this article, visit the following pages:


Other Resources:

7.7.10

How to POST pictures into Blogger

 

  1. Upload an image to Picasa
  2. Get the URL of the image.
  3. Create your post in HTML mode with the <img> tag and set the src attribute with the URL from your Picasa album.

Message from QQ

RT @ag108lau: 蔡康永:15岁觉得游泳难,放弃游泳,到18岁遇到一个你喜欢的人约你去游泳,你只好说“我不会耶”。18岁觉得英文难,放弃英文,28岁出现一个很棒但要会英文的工作,你只好说“我不会耶”。人生前期越嫌麻烦,越懒得学,后来就越可能错过让你动心的人和事...

That is: 少壮不努力,老大徒伤悲

Google Blogger APIs (Lab)

Developer's Guide: Java

The Blogger Data API allows client applications to view and update Blogger content in the form of Google Data API feeds.

Your client application can use the Blogger Data API to create new blog posts, edit or delete existing blog posts, and query for blog posts that match particular criteria.

In addition to providing some background on the capabilities of the Blogger Data API, this document provides examples of basic Data API interactions using the Java client library. If you're interested in understanding more about the underlying protocol that the library uses, see the Protocol section of this developer's guide.

Contents

  1. Audience
  2. Getting started
    1. Creating a Blogger account
    2. Running the sample code
  3. Authenticating to the Blogger service
    1. AuthSub proxy authentication
    2. ClientLogin username/password authentication
  4. Retrieving a list of blogs
  5. Creating posts
    1. Publishing a blog post
    2. Creating a draft blog post
  6. Retrieving posts
    1. Retrieving all blog posts
    2. Retrieving posts using query parameters
  7. Updating posts
  8. Deleting posts
  9. Comments
    1. Creating comments
    2. Retrieving comments
    3. Deleting comments

Audience

This document is intended for programmers who want to write Java client applications that can interact with Blogger.

This document assumes that you understand the general ideas behind the Google Data APIs protocol.

For reference information about the classes and methods provided by the client library, see the Java client library API reference. For general Blogger Data API reference information, see the Protocol reference guide.

Getting started

For help setting up the client library, see the Getting Started Guide.

The Java client library requires Java 1.5. After downloading the client library, you'll find the classes you need to get started in the java/lib/gdataclient-1.0.jar file.

Creating a Blogger account

You may want to sign up for a Blogger account for testing purposes. Blogger uses Google Accounts, so if you already have a Google account, you're all set.

Running the sample code

A full working sample client, containing all the sample code shown in this document, is available in the Java client library distribution, under the directorygdata/java/sample/blogger/BloggerClient.java. Build and execution instructions are included in the same directory in the README.txt file.

The sample client performs several operations on the provided blog to demonstrate the use of the Blogger Data API.

To compile the examples in this document into your own code, you'll need the following import statements:

import com.google.gdata.client.*;
import com.google.gdata.data.*;
import com.google.gdata.util.*;
import java.io.IOException;
import java.net.URL;

Authenticating to the Blogger service


You can access both public and private feeds using the Blogger Data API. Public feeds don't require any authentication, but they are read-only. If you want to modify blogs, then your client needs to authenticate before requesting private feeds. It can authenticate using either of two approaches: AuthSub proxy authentication orClientLogin username/password authentication.

For more information about authentication with Google Data APIs in general, see the authentication documentation.

Most of the samples in subsequent sections of this document assume you have an authenticated GoogleService object.

AuthSub proxy authentication

AuthSub proxy authentication is used by web applications that need to authenticate their users to Google Accounts. The website operator and the client code don't have access to the username and password for the Blogger user; instead, the client obtains special AuthSub tokens that allow the client to act on a particular user's behalf. For more detailed information, see the AuthSub documentation.

When a user first visits your application, they have not yet been authenticated. In this case, you need to display some information and a link directing the user to a Google page to authenticate your request for access to their blogs. The Java client library provides a function to generate the Google page's URL. The code below retrieves the URL of the AuthSubRequest page:

String next = "http://www.example.com/welcome.html";
String scope = "http://www.blogger.com/feeds/";
boolean secure = false;
boolean session = true;
String authSubLogin = AuthSubUtil.getRequestUrl(next, scope, secure, session);

The getRequestUrl method takes the following parameters (corresponding to the query parameters used by the AuthSubRequest handler):


next
The URL of the page that Google should redirect the user to after authentication.
scope
Indicates that the application is requesting a token to access Blogger feeds. The scope string to use is http://www.blogger.com/feeds/ (URL-encoded, of course).
secure
Indicates whether the client is requesting a secure token.
session
Indicates whether the token returned can be exchanged for a multi-use (session) token.

The above example shows a call that doesn't request a secure token (the value of secure is false). The resulting request URL might look like this:

https://www.google.com/accounts/AuthSubRequest?scope=http%3A%2F%2Fwww.blogger.com%2Ffeeds%2F&session=1&secure=0&next=http%3A%2F%2Fwww.example.com%2Fwelcome.html

The user follows the link to Google's site and authenticates to their Google Account.

After the user authenticates, the AuthSub system redirects them to the URL you specified in the next query parameter of the AuthSubRequest URL. The AuthSub system appends an authentication token to that URL, as the value of the token query parameter. For example:

http://www.example.com/welcome.html?token=yourAuthToken

This token value represents a single-use AuthSub token. In this example, since session = true was specified, this token can be exchanged for an AuthSub session token by calling the AuthSubSessionToken service, as follows, where urlFromAuthSub is the URL that AuthSub appended the token to:

String token = AuthSubUtil.getTokenFromReply(urlFromAuthSub);
String sessionToken = AuthSubUtil.exchangeForSessionToken(token, null);

That is, you pass your one-time-use token to the exchangeForSessionToken method, along with either null (for unregistered mode) or a private key (for registered mode), and the AuthSub interface returns a session token. For more information about registered applications and private keys, see the "Signing requests" section of the AuthSub documentation.

Your application can then use the session token in subsequent interactions with Blogger. To tell the Java client library to automatically send the session token with each request, call the GoogleService object's setAuthSubToken method:

GoogleService.setAuthSubToken(sessionToken, null);

After that, the client library automatically sends the token along with every request.

ClientLogin username/password authentication

Use ClientLogin authentication if your client is a standalone, single-user "installed" client (such as a desktop application). Just call the setUserCredentialsmethod on your GoogleService object and all subsequent interactions with Blogger will be authenticated:

GoogleService myService = new GoogleService("blogger", "exampleCo-exampleApp-1");
myService.setUserCredentials("user@example.com", "secretPassword");

In the snippet above, we pass two parameters to the GoogleService constructor. The first parameter is the name of the service we want to interact with. The second parameter is the name of our application in the form companyName-applicationName-versionID.

For more information about ClientLogin authentication, including sample requests and responses, see the Authentication for Installed Applications documentation.

Note: Use the same token for all requests in a given session; don't acquire a new token for each Blogger request.

Note: As described in the ClientLogin documentation, the authentication request may fail and request a CAPTCHA challenge. If you want Google to issue and handle the CAPTCHA challenge, then send the user to https://www.google.com/accounts/DisplayUnlockCaptcha?service=blogger (rather than to the CAPTCHA-handling URL given in the ClientLogin documentation).

Retrieving a list of blogs


The Blogger Data API provides a feed that lists the blogs for a particular user; that feed is known as a "metafeed."

The following sample code uses an authenticated GoogleService object to retrieve the metafeed and then prints each blog's title.

public static void printUserBlogs(GoogleService myService)
throws ServiceException, IOException {

// Request the feed
final URL feedUrl = new URL("http://www.blogger.com/feeds/default/blogs");
Feed resultFeed = myService.getFeed(feedUrl, Feed.class);

// Print the results
System.out.println(resultFeed.getTitle().getPlainText());
for (int i = 0; i < resultFeed.getEntries().size(); i++) {
Entry entry = resultFeed.getEntries().get(i);
System.out.println("\t" + entry.getTitle().getPlainText());
}
}

Note the URL used by the getFeed method. This is the default metafeed URL; it returns a list of blogs for the currently authenticated user. To access a feed for a different user, you can put the user's ID in place of default in the metafeed URL. The user's ID is the string of digits at the end of the user's profile URL.

Creating posts


The Blogger Data API allows you to create and publish new blog entries, as well as creating drafts of entries.

Note: Setting a custom author for posts is currently not supported. All new posts will appear as if they were created by the currently authenticated user.

Publishing a blog post

You can use the Java client library to publish new blog entries.

First, create an Entry object to represent the blog post. Then you can set the title, content and other attributes of the blog post. Finally, use the GoogleServiceobject to insert the post. Here's an example of how to publish a new blog post:

public static Entry createPost(
GoogleService myService, String blogID, String title,
String content, String userName)
throws ServiceException, IOException {
// Create the entry to insert
Entry myEntry = new Entry();
myEntry.setTitle(new PlainTextConstruct(title));
myEntry.setContent(new PlainTextConstruct(content));

// Ask the service to insert the new entry
URL postUrl = new URL("http://www.blogger.com/feeds/" + blogID + "/posts/default");
return myService.insert(postUrl, myEntry);
}

The insert method takes the service's post URL as a parameter. Then the method returns the entry as it was stored by Blogger. The entry returned is the same one you sent, but it also contains various elements added by Blogger, such as a post ID.

If your request fails for some reason, Blogger may return a different status code. For information about the status codes, see the Google Data API protocol reference document.

Creating a draft blog post

Draft posts are created in the same way as public posts, but you need to set the draft attribute of the Entry object. You can create a blog post like the one above as a draft by adding the highlighted line:

public static Entry createPost(GoogleService myService, String blogId,
String title, String content, String userName,
Boolean isDraft)
throws ServiceException, IOException {
// Create the entry to insert
Entry myEntry = new Entry();
myEntry.setTitle(new PlainTextConstruct(title));
myEntry.setContent(new PlainTextConstruct(content));
myEntry.setDraft(isDraft);

// Ask the service to insert the new entry
URL postUrl = new URL("http://www.blogger.com/feeds/" + blogID + "/posts/default");
return myService.insert(postUrl, myEntry);
}

You can turn an existing draft blog post into a published post by retrieving the draft post, setting the draft attribute to false, and then updating the post. We'll cover retrieving and updating posts in the next two sections.

Retrieving posts


The following sections describe how to retrieve a list of blog posts, with and without query parameters.

You can query a Blogger public feed without authentication. Therefore, you don't need to call the setUserCredentials method or do AuthSub authentication before retrieving posts from a public blog.

Retrieving all blog posts

To retrieve the user's posts, call the same getFeed method used to retrieve the blogs metafeed, but this time send the blog-post feed URL:

public static void printAllPosts(
GoogleService myService, String blogId)
throws ServiceException, IOException {
// Request the feed
URL feedUrl = new URL("http://www.blogger.com/feeds/" + blogID + "/posts/default");
Feed resultFeed = myService.getFeed(feedUrl, Feed.class);

// Print the results
System.out.println(resultFeed.getTitle().getPlainText());
for (int i = 0; i < resultFeed.getEntries().size(); i++) {
Entry entry = resultFeed.getEntries().get(i);
System.out.println("\t" + entry.getTitle().getPlainText());
}
System.out.println();
}

Retrieving posts using query parameters

The Blogger Data API lets you request a set of entries that match specified criteria, such as requesting blog posts published or updated in a given date range. To do this, you create a Query object and pass it to the GoogleService.getQuery method.

For example, to send a date-range query, use the setPublishedMin and setPublishedMax methods of the Query object. The following code snippet prints the title of each blog post published between the given start time and end time:

public static void printDateRangeQueryResults(
GoogleService myService, String blogId,
DateTime startTime, DateTime endTime)
throws ServiceException, IOException {
// Create query and submit a request
URL feedUrl = new URL("http://www.blogger.com/feeds/" + blogID + "/posts/default");
Query myQuery = new Query(feedUrl);
myQuery.setPublishedMin(startTime);
myQuery.setPublishedMax(endTime);
Feed resultFeed = myService.query(myQuery, Feed.class);

// Print the results
System.out.println(resultFeed.getTitle().getPlainText() +
" posts between " + startTime + " and " + endTime);
for (int i = 0; i < resultFeed.getEntries().size(); i++) {
Entry entry = resultFeed.getEntries().get(i);
System.out.println("\t" + entry.getTitle().getPlainText());
System.out.println("\t" + entry.getUpdated().toStringRfc822());
}
System.out.println();
}

Notice that the Query object is constructed using the same post feed URL used to retrieve posts.

The Blogger Data API supports the following Query methods:


addCategoryFilter
Specify categories (also known as labels) to filter the feed results. For example, http://www.blogger.com/feeds/blogID/posts/default/-/Fritz/Laurie returns entries with both the labels Fritz and Laurie.
setMaxResults
Set the maximum number of entries to return.
setPublishedMin, setPublishedMax
Set the bounds on entry publication dates.
setStartIndex
Set the 1-based index of the first result to be retrieved (for paging).
setUpdatedMin, setUpdatedMax
Set the bounds on entry update dates. These query parameters are ignored unless the orderby parameter is set to updated.

Note: There are currently no setters for the orderby query parameter. However, you can still use the Query.addCustomParameter() method if you need to set this.

For more information about query parameters, see the Blogger Data API Reference Guide and the Google Data APIs Reference Guide.

Updating posts


To update an existing blog post, first you retrieve the entry you want to update, then you modify it, and then you send it to Blogger using the update method. The following code snippet modifies the title of a blog entry, assuming that you've already retrieved the entry from the server.

public static Entry updatePostTitle(
GoogleService myService, Entry entryToUpdate, String newTitle)
throws ServiceException, IOException {
entryToUpdate.setTitle(new PlainTextConstruct(newTitle));
URL editUrl = new URL(entryToUpdate.getEditLink().getHref());
return myService.update(editUrl, entryToUpdate);
}

The above code returns an Entry containing the entire newly-updated post. To update any other properties, simply set them in the Entry object before callingupdate.

Note: Modifying the author data associated with posts is currently not supported.

Deleting posts


To delete a post, pass the post's edit URL to the delete method on your GoogleService object, like this:

public static void deletePost(
GoogleService myService, String editLinkHref)
throws ServiceException, IOException {
URL deleteUrl = new URL(editLinkHref);
myService.delete(deleteUrl);
}

Comments


The Blogger Data API allows for creating, retrieving, and deleting comments. Updating comments is not supported (nor is it available in the web interface).

Creating comments

To post a comment, create an Entry object and insert it as follows:

public static Entry createComment(
GoogleService myService, String blogID, String postId,
String commentText)
throws ServiceException, IOException {
// Build the comment feed URI
String commentsFeedUri = "http://www.blogger.com/feeds/" + blogID + "/" + postId + "/comments/default";
URL feedUrl = new URL(commentsFeedUri);

// Create a new entry for the comment and submit it to the GoogleService
Entry myEntry = new Entry();
myEntry.setContent(new PlainTextConstruct(commentText));
return myService.insert(feedUrl, myEntry);
}

Note: Currently, you can only post comments to a blog owned by the authenticated user.

Note: Setting a custom author for comments is currently not supported. All new comments will appear as if they were created by the currently authenticated user.

Retrieving comments

You can retrieve the comments for a particular post from the post's comments feed URL:

public static void printAllComments(
GoogleService myService, String blogID, String postId)
throws ServiceException, IOException {
// Build comment feed URI and request comments on the specified post
String commentsFeedUri = "http://www.blogger.com/feeds/" + blogID + "/" + postId + "/comments/default";
URL feedUrl = new URL(commentsFeedUri);
Feed resultFeed = myService.getFeed(feedUrl, Feed.class);

// Display the results
System.out.println(resultFeed.getTitle().getPlainText());
for (int i = 0; i < resultFeed.getEntries().size(); i++) {
Entry entry = resultFeed.getEntries().get(i);
System.out.println("\t" +
((TextContent) entry.getContent()).getContent().getPlainText());
System.out.println("\t" + entry.getUpdated().toStringRfc822());
}
System.out.println();
}

Or you can get the comments from all posts by using the blog's comments feed URL:

http://www.blogger.com/feeds/blogID/comments/default

Deleting comments

To delete a comment, pass the comment's edit URL to the delete method on your GoogleService object like this:

public static void deleteComment(GoogleService myService, String editLinkHref)
throws ServiceException, IOException {
URL deleteUrl = new URL(editLinkHref);
myService.delete(deleteUrl);
}
 
http://code.google.com/apis/blogger/docs/2.0/developers_guide_java.html

Introduction to Blogger Data API – Client Applications

This article introduces the reader who has to learn basic programming Blogger Data API and use it as a Blogger Client Applications. Where a programmer can then design their own on Tools Blogger Editor Desktop Applications, Browser Plug-ins, even able to design their own applications Blog Aggregator. For example you would never use one of the tools on desktop applications and online services, with these tools we can edit, delete, and update blogs content without having to login directly to the actual engine. Here I am sure you already have an idea of how the blog editor to work, tools, this is what I mean later on as one example of Blogger Client Applications.

Learning the Blogger Data API means that we (programmers) as the developer is authorized to use it. Before the study it needs to know about Blogger Data API is part of one of Google’s data services APIs (Gdata). This Gdata format uses two XML-based standards are ATOM and RSS. Gdata which is the simple standard protocol used to facilitate the process of reading and writing data on the web. To learn more about Gdata can be read at this address:http://code.google.com/apis/gdata/overview.html

Introduction to Blogger Data API
Blogger Data API allows third parties (developers) to display and update the content of blogger content data acquisition process through the Google Data API feeds. we can edit the content of the posting, delete and update it, not until we log onto the system. There we can also send and delete comments that have been published previously.

For a basic introduction about the blogger API data there are 3 steps to begin to study it, the first study used the Google data APIs, proceed to the next step of the Blogger Data API Developer’s Guide or you can read further guidance here Reference Guide if necessary can read more here http://code.google.com/apis/blogger/

Programming
There are several ways that can be taken to make the client application, if you are on page Developer’s Guide: Protocol was fully described there programming language you can use, until now there are five standard programming language support you can learn, including:

*.NET
* Java
* JavaScript
* PHP
* Python

If you asked which one was much easier then I will answer all of them difficult, which makes it easy to be determined in accordance with the basic programming your own. If I had to choose the option would be to fall into Javasript .Net. One of the most recommended option, should you choose to JavaScript only, because there have been included tutorials and sample code and output the results you certainly can try it immediately. you can see more here

Standard Authentication (proof of authenticity)
Standard Authentication is a protocol that allows a user to perform Authentication (authentication), Authorize (authority / entitlements) to the user or users who want to access a system or service from a central server computer networks. Authentication is also required when we want to do on the network access Blogger (Google) is a way to enter username and password. In Servies Authentication to be able to access our Blogger Bloggers with two ways of using the right of Private and Public Feeds. Usually does not require public feeds we use Authentication, unlike the Private Feeds Authentication requires that we do first.

Sample Applications

Using Visual Basic.Net
To facilitate you to understand how the Blogger Data API below I include the source code using VB.Net. These tools I’ve ever brush past the end of 2007, with this tool you will understand how to backup blogger using Gdata access via Feeds Blogger Backup Utility(VB.Net open source)

Using the JavaScript Client Library
Blog.Gear really is one of the Google Gear project which plans to use this service to access applications on Blogger Offline mode. However the you can try to learn the application using the Blogger Data API. You also can learn the source code here, for the video you can refer here.

This paper is only a basic introduction and of course still far from perfect. Hopefully useful:).

5.7.10

A Message from QQ

李开复:Andy Rubin创立了两个手机操作系统公司:Danger和Android。Danger 5亿美元卖给微软,今年成为了Kin,48天销售1万台,上周寿终正寝。Android4千万美元卖给Google,今年销售大约6千万台。Andy是我1990年在苹果认识的第一位工程师,当时他要把“电话做进电脑”,结果把“电脑做进了电话”。