Monday, October 27, 2008

Set Up Email Automatic Polling


To automate the email polling and blog posting process in WordPress, you need to schedule a recurring task that loads the wp-mail.php script at fixed intervals (e.g., every five minutes). You need two tools for this: a lightweight URL loader called curl to load the PHP script, and the open source cron daemon to schedule the recurring URL loading tasks. Both cron and curl are installed by default on Linux, Unix, and Mac OS X computers. For Windows, you can install the Cygwin toolkit (http://www.cygwin.com/)to get a common set of Unix utilities including cron and curl.

You can use a fully featured web browser, such as Firefox, to load the wp-mail.php script every five minutes. But that is a huge waste of server resources.


Next, log into your server and type the following on the command line:

crontab e

This opens the cron control file, which contains all scheduled tasks, in the system's default text editor. You should append one line to the bottom of the file, save it, and exit the editor. cron automatically reloads the control file.

*/5 * * * * /usr/local/bin/curl http://yourdomain/wp-mail.php > /dev/null

The preceding line in the cron control file schedules the system to run the curl command in the last part of the line every five minutes in every year, month, week, and day. That's it! You now have a fully functional photo moblog server.

If you do not want to use the default editor, you can always export the cron control file to a text file, edit it externally, and then import the edited file back to crontab. See the crontab manual page for more information.

Email Posting with WordPress


WordPress supports email posting, albeit with two main drawbacks. First, it does not support email attachments. And second, it does not filter the sender's email address. Anyone can send email to the email address and have their messages appear on your blog. Without sender-address filtering, your moblog can be easily flooded with spam messages.

A patch by "lansmash" fixed both drawbacks. Applying the patch is straightforward. First, download the file wp-mail-0.2.zip from the web address http://blade.lansmash.com/index.php?cat=5. Unzip the archive to the WordPress root directory. This adds the files PEAR.php and mimedecode.php to the directory and replaces the original wp-mail.php file. Now, create two directories, wp-photos and wp-filez, under the WordPress root directory to store images and other attachments, respectively. You can choose other directory names as long as you remember to modify the corresponding settings in the new wp-mail.php file.

If you want automatic picture resizing (an important feature for megapixel camera phones), you need to install an additional hack provided by "Hugo." Simply replace the default wp-mail.php file in your WordPress installation with a new file downloaded from http://www.vienna360.net/files/wp-mail.phps.

Now, you can test your setup by sending an email message with a picture attachment to the email address specified in the Options Writing section of the WordPress configuration page. Make sure you enter the correct server and login information. Nothing appears on your blog just yet. That is because the wp-mail.php script needs to be manually loaded to poll the email server for the new message. Do this by pointing your browser to http://your-domain-name/MyMoblog/wp-mail.php.

Of course, if you need to open a browser and load the wp-mail.php script manually every time you post a moblog entry, it defeats the whole point of moblogging. So, let's discuss how to automate the email polling process in WordPress.

Set Up WordPress


WordPress (http://www.wordpress.org/) is an open source blog server based on PHP and MySQL. It is available free of charge from the WordPress web site. You can run it on your own server or on any Internet Service Provider (ISP) server account that supports PHP and MySQL .

As a PHP and MySQL application, WordPress runs on almost any modern operating system, including Linux, Unix, BSD, Windows, and Mac OS X.

By following the installation instructions (see http://wordpress.org/docs/installation/5-minute/) you can install WordPress in five minutes. After creating a user account, you can start to post and publish blogs on your very own blog server now! Out of the box, you can use Flickr to post photos to your freshly installed WordPress server. In the rest of this hack, I will discuss how to set up WordPress so that you can moblog with it without

Set up and run your own servers for moblogging!

Many power bloggers run their own blogging server so that they can have complete control over the content and presentation of their blog. While Flickr can interoperate with many popular blog systems, it is still a "hosted" service that is beyond the blogger's control. For instance, there is no guarantee that the free Flickr service won't be replaced by a for-pay service in the future. If you want complete end-to-end control over your moblog, you can customize existing blog server software to make it support email posting with photo attachments from a mobile phone. In this hack, you will learn how to set up the popular WordPress blog server to support photo moblog postings.

Running your own server also gives you complete access to web site visitor statistics, the ability to back up the web site, and many other features.

Smart client for Flickr.


The default email application on some Nokia phones restricts the size of an attachment to a maximum of 100 KB. To get around this limitation and to provide a more integrated user experience, you can use a phone application that takes pictures and then automatically posts them to Flickr without having to switch applications and enter email addresses.

"Manoj TK" wrote a little open source J2ME program that does just that. You can download it from https://sourceforge.net/projects/moblogger2/.To learn how the program works, please refer to http://manojtk.blogspot.com/2005/01/smtp-email-attachments-from-nokia-6600.html.

Photo Moblogging to Any Blog Service

The aforementioned photo moblogging solutions tie you into specific bloghosting services. But in many cases, you do not want this tie-in:

You could be running your own blog server and do not use any of the blog hosting services.

Your favorite blog host might not provide photo moblogging features.

You might not want to pay the extra money to add photo moblogging support.

Is there a service that is free and independent of your blog server? As it turns out there is, and it's called Flickr.

Flickr (http://www.flickr.com) started out as a photo storage provider. The one feature that makes Flickr really interesting from a moblog point of view is that it allows you to upload photos (to Flickr) by email and create a blog entry at your designated blog site. The blog site can be any of the blog hosts mentioned in the previous section, or even your own web site running popular blog server software.

The post includes the email content as its main body and an inline thumbnail, which is linked to the picture stored on Flickr. The thumbnail posting feature in Flickr is really cool and sets it apart from other services, especially if you have a camera phone that produces megapixel pictures. Without resizing to thumbnails, megapixel pictures would clutter up your blog and mess up the web page layout (e.g., sidebars, etc.).

The free account at Flickr allows you to upload up to 20 MB of photos per month. A subscription fee of $24.95 per year will push the quota to 2 GB per month. Considering most (mobile phone) moblog attachments are smaller than 100 KB, the free Flickr account is more than sufficient for even the most aggressive mobloggers. Combining the Flickr email posting service with a free blog-hosting service (or your own blog server), you can set up a powerful and free moblog with photo posting in no time!

Saturday, October 4, 2008

Email Moblogging


If your mobile phone supports sending email or MMS, email moblogging doesn't have any of the drawbacks of SMS moblogging:

There is no practical length limitation, as long as your thumbs don't complain.
You can post photos from a camera phone, adding richness to your post.
There is no extra charge besides what you pay for the wireless data and regular blog hosting service.

Email moblogging works in much the same way as its SMS counterpart, except that you send email from the phone to a (hopefully) secret email address. The email Inbox is polled by the moblog service at regular intervals (e.g., every five minutes). When a new message is detected, the moblog service retrieves the message and parses the content. If the moblog service supports picture attachments (most do), you can even have a mobile photo blog!

It is important that you keep the email address private. Any message sent to that email address will be automatically posted on your blog.

The easiest way to set up an email-based moblog is to use a blog-hosting service that supports email posting. It typically takes only a few minutes. After you open a regular blog account at the hosting service, there is usually a field under the user preferences screen where you can set the private email address. All emails sent to this address will be posted to the blog you just opened.

Most popular blog-hosting providers now support email posting from mobile phones, either free of charge (e.g., Blogger) or with a premium paid account (e.g., LiveJournal).
Besides the major blog providers, some new providers specialize in moblog hosting. Among them are Textamerica (http://www.textamerica.com) and Fotolog (http://www.fotolog.net). Both of them offer free accounts for users to blog directly from their mobile phones.
The free accounts often come with the condition that the service provider can display advertisements on your blog pages.

SMS Moblogging

SMS moblogging works on any handset that can send SMS, which is virtually every mobile phone nowadays. You write the blog entry on the mobile phone and send it via SMS to a service phone number provided by a moblog service. The moblog service interprets the received SMS message and posts it to your blog. You can be identified by the caller ID or an ID code embedded in the SMS message. A good example of such an SMS moblog service is Txtsolutions (http://blog.txtsolutions.com). Txtsolutions can host your blog on its own site, or post your blog entries to your account in a list of supported third-party blog hosts.
If the SMS moblog service posts the blog entries to a third-party blog host on your behalf, it needs to know your login information on that third-party site.

Despite the meager prerequisite of the handset, SMS moblogging has some major drawbacks. First is the nagging 160-character limitation for SMS. Second, even if you are laconic enough to squeeze each of your posts into fewer than 160 characters (not words), SMS moblogging is text-only. Third, you need to pay extra to the SMS moblog service provider. For example, Txtsolutions charges £0.10 for each message. This charge is in addition to your regular SMS fee (from your wireless operator) and cost for the blog hosting service if it applies.

Post to Your Blog from your Smartphone

Use a mobile blogging service to post blog entries with pictures from your mobile phone.

Not long ago, bloggers could only update their blogs using a computer. Inspiration, however, does not always coincide with the presence of a bulky computer. At the turn of the century, some adventurous and creative bloggers started blogging from their mobile devices. The word moblog was thus coined, referring to blogging from a mobile device (mobile phones, PDAs, etc.).

If blogging without a computer is convenient, moblogging with a camera phone is exciting. In just a few clicks you can snap a quick shot and add a few punch lines, and minutes later the neatly formatted post on your personal blog can be shared with the entire world! Figure 9-31 shows a snapshot of O'Reilly editor Brian Jepson's moblog. You can see Brian's world through pictures taken from his phone camera and comments that captured his instantaneous thoughts. (That dry spell between November and March? That's when Brian used a phone without a camera for a few months before switching back to his Nokia 3650.)

There are two major approaches to moblogging, regardless of the myriad phone models and their different capabilities: SMS moblogging and email moblogging. This hack introduces and compares these two methods, with an emphasis on the latter.

Instead of email, you can also use MMS to post blog entries from your camera phone. The MMS message is sent to an email address, and hence, MMS moblogging is essentially the same as email moblogging.