wordpress.com recently announced a great feature: the ability to create a blog post by simply calling a phone number and leaving a message, which shows up as an audio post on your blog. judging by the enthusiastic comments from wordpress users, this is a feature many wanted – including me.
unfortunately, the “phone your blog” feature was only made available for blogs hosted on wordpress.com – not on self-hosted installations. but don’t worry, you can actually set that up yourself – with just a little tinkering (and a small investment, if you want a non-us phone number).
basically, what you do is this:
- set up an account at twilio.com (free basic account will do)
- install the wordpress plugin “postie“, to allow posting via email with attachments
- follow the tutorials at twilio.com to create a php/xml script which greats a caller and records a message
- send the recorded message by email to your blog, including the recorded soundfile as an attachment
in order to complete steps 3 and 4 you need some basic knowledge of php and xml. but it is not overly complicated – i am no professional programmer, and got it set up and working in a couple of days. step 3 is well covered by the twilio tutorials.
as for step 4, how to do it is fairly well described by Tim at texelate.co.uk. however, notice that there are some errors in the code, probably due to formatting – the ‘\r\n’ parts of the mime lines are messed up, and at least for me the quotation marks also came out wrong after copying and pasting into dreamweaver. so for copying code lines, it might be better to go to this daniweb forum thread or this codewalkers page.
notice also that you are here dealing with a file passed as a url to the php script (by twilio), so if your server does not allow you to open urls with fopen (as in my case), you have to use curl instead. the significant lines are, for me:
// prepare file attachment
$fileatttype = “audio/mpeg”;
$fileattname = “FILENAME.mp3”;
…and from there just skip the fopen part of Tim’s script, the $data variable now contains the contents of the file and can be used to enter the file into the email using:
$data = chunk_split( base64_encode( $data ) );
…as done in Tim’s script.
bonus point: twilio only provides you with a u.s. number for incoming calls. in other words, you and the users of your blog need to call a u.s. number to leave your message. for me, as i am based in norway and am inviting members of the public to post messages in my blog, this was not a satisfactory solution – i can’t expect people to be willing to make international calls just to post to my blog. the solution? i set up a norwegian phone number which automatically forwards callers to the u.s. number provided by twilio. doesn’t cost me much – around 2.50 nok per minute (0.30 euros), i think – and as i will have a limited number of messages i expect the total expense to be less than 1-2000 nok.
my working solution can be tried out at the flannør blog – however, for the moment it is in norwegian only… feel free to ask any questions in the comments though, and i will be happy to answer as best i can (again, i am no pro in this so cut me some slack if i can’t answer).