|
You cant get away from it, Twitter that is, Everyone is either tweeting or writing about tweeting, Just sticking twitter into search on the BBC website and you will get over 500 unique results from the BBC alone. Stephen Fry has over a million followers ! .
So I thought that there must be something else that this could be used for, And it came to me "Asterisk Voicemail Notification" Obviously you don't want everyone to know you have a voicemail (Well I hope not) but this is easily solved by creating a private account for the server that only selected followers can see, and then send the notifications as "Direct Messages", Easy I thought and to be honest it is.
Firstly you need a bit of PHP code to post the tweets. This is well documented and the version we have used is here.
<?php $username = 'USERNAME'; $password = 'SECRET'; $destuser = $_GET[destuser]; $message = $_GET[message]; $tweet = "d $destuser $message"; echo "$tweet"; $status = urlencode(stripslashes(urldecode($tweet))); echo "$status"; if ($status) { $tweetUrl = 'http://www.twitter.com/statuses/update.xml'; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, "$tweetUrl"); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, "status=$status"); curl_setopt($curl, CURLOPT_USERPWD, "$username:$password"); $result = curl_exec($curl); $resultArray = curl_getinfo($curl); echo $resultArray['http_code']; if ($resultArray['http_code'] == 200) echo 'Tweet Posted'; else echo 'Could not post Tweet to Twitter right now. Try again later.'; curl_close($curl); } ?>
The only things you will need to change are the username and password. The user you are sending the message to and the message are sent in the GET from Asterisk. You will see that we have fixed this as a direct message by the 'd' at the start of the message. you could change this if for example you wanted to use this code for normal tweeting.
Next we need the code for Asterisk to say it has a message, We have added this to our 'h' extension of the of the std-exten-macro you could add it where you want. The user that the tweet is sent to is stored in the ASTDB and recalled and assigned to the variable ${destacc}
|
Set(foo=${CURL(http://<SERVERADDRESS>/tweet.php?destuser=${destacc}& //
message=Caller%20${CALLERID(num)}%20left%20a%20new%20voicemail%20 //
number%20${nvmcount}%20at%20${STRFTIME(${EPOCH},,%d%m%H%M)})});
|
Please note the %20 for any space in the string must remain and the // denote that ive split the line. Also if we Noop ${foo} we can see the result back from Twitter.
This does rely on using a compatible dialplan, which on request I can make available, We already had it in place as we already notify new voicemails by SMS
I'm sure there are many other uses for this and your imagination is the only hurdle now to getting your Asterisk Tweeting, For example we are also tweeting Missed calls and callback requests.
|