Home > Uncategorized, php > Create a simple Twitter IM bot

Create a simple Twitter IM bot

October 12th, 2008

Some time back I worte a post about a Twitter Google bot in www.crankup.net. As promised, here is how you can develop your own google talk bot which can post your messages to Twitter.

First, You need an imified account for your bot to work properly. Get one here. Once the account is created, login to your account and give your new bot a name. I call it Post2Twitter.

Now its time to develop the bot. I have used PHP to post message from the chat window to twitter.Below is the code.

<?php
error_reporting(0);
require('twitterAPI.php');
$message = $_REQUEST['msg'];
if(isset($message))
{
$extracted = explode("$",$message);
$twitter_username = $extracted[0]; 
$twitter_psw = $extracted[1];
$twitter_message = $extracted[2];
 
if(strlen($twitter_message)<1){
	echo "Sorry! Please enter a message to post!";
	exit(0);
	} else {
	$twitter_status=postToTwitter($twitter_username, $twitter_psw, $twitter_message);
	}
}
 ?>

Looks simple? Infact it is not. I have used anoter file which will post the message to twitter. Get the include file here.

Now upload both the files to a webserver and provide the url in your bot setting page (imified.com).Once this is done you can invite your bot to your google talk and start having fun. The above code is self explanatory if you have any queries please post it as a comment.

[Post to Twitter]   [Post to Plurk]   [Post to Digg]   [Post to ping.fm]

Related posts

Shoban Uncategorized, php

  1. April 19th, 2009 at 01:47 | #1

    a good example to learn, but not a good application….you could have manage states. Thanx for sharing :)

  2. April 19th, 2009 at 01:49 | #2

    Yes Vaibhav .. You are right its good for learning only :) No security as pwd are clear text. Thanks for your comment.

  1. No trackbacks yet.