11.4 Viewing the Blogger Post

 < Day Day Up > 

You can see the results of a post to the Blogger weblog system in Figure 11-3.

Figure 11-3. Blogger-generated post
figs/rww_1103.gif


Similar to LiveJournal, the actual display and formatting of the posts is governed by the Blogger templates.

For completeness, Example 11-7 shows a utility class that assists with converting a string to an MD5 hash, as used in the LiveJournal access code. An MD5 hash is a one-way hash; it allows you to discover a unique "fingerprint" of a lump of text without being able to recover the original string. It's commonly used to store passwords in a database, for example.

Example 11-7. MD5 hash example
package com.cascadetg.ch11; import java.security.*; public class MD5Hash {     /**      * Private function to turn md5 result into a properly formatted 32      * hex-digit string      */     private static String asHex(byte hash[])     {         StringBuffer temp = new StringBuffer(hash.length * 2);         int i;         for (i = 0; i < hash.length; i++)         {             if ((hash[i] & 0xff) < 0x10)                 temp.append("0");             temp.append(Long.toString(hash[i] & 0xff, 16));         }         return temp.toString( );     }     /**      * Take a string and return its md5 hash as a hex digit string      */     public static String hash(String arg)     {         return hash(arg.getBytes( ));     }     /**      * Take a byte array and return its md5 hash as a hex digit string      */     public static String hash(byte barray[])     {         Provider[] providers = java.security.Security.getProviders( );         Provider myProvider = null;         for (int i = 0; i < providers.length; i++)         {             if (providers[i].getName( ).compareTo("SUN") == 0)             {                 myProvider = providers[i];             }         }         if (myProvider == null)         {             return "Unable to load Sun security package";         }         MessageDigest md = null;         try         {             md = MessageDigest.getInstance("MD5");         } catch (java.security.NoSuchAlgorithmException e)         {             return "Unable to load Sun security provider";         }         md.update(barray);         return asHex(md.digest( ));     } }

Finally, as shown in Example 11-8, you must enter the username and password for your preferred service.

Example 11-8. Weblog tokens
package com.cascadetg.ch11; public class BlogTokens {     /* LiveJournal tokens */     static public String livejournal_username = "username";     static public String livejournal_password = "secret_password";     /* Blogger tokens */     static public String blogger_app_key =         "01234567890123456789012345678901"             + "12345678901234567890123456789012"             + "12345678901234567890123456789012";     static public String blogger_blogid = "1234567";     static public String blogger_username = "other_username";     static public String blogger_password = "other_password"; }

A weblog provides an efficient and simple way to integrate content. The formatting and design are separate from the content. A simple web service interface allows one system to generate content and post it in an automated fashion to another.

We've seen that much of the work to be done with web services is really a question of system integration. The final chapter ponders what this means for web services, and what the future of web services may look like.

     < Day Day Up > 


    Real World Web Services
    Real World Web Services
    ISBN: 059600642X
    EAN: 2147483647
    Year: 2006
    Pages: 83
    Authors: Will Iverson

    Similar book on Amazon

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net