May 16, 2009, 11:05 p.m.
posted by clayrat
Host Your Own Mobile Photo Blog

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 [Hack #56] 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.
|
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 4.1 and MySQL 3.23.23 or greater.
|
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 [Hack #56]. In the rest of this hack, I will discuss how to set up WordPress so that you can moblog with it without needing a third-party service.
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 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.
|
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.
|
Haihao Wu
- Comment
