<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SMM Guru - The Social Media Marketing Guru &#187; TwitterBot</title>
	<atom:link href="http://www.smmguru.com/category/twitterbot/feed" rel="self" type="application/rss+xml" />
	<link>http://www.smmguru.com</link>
	<description></description>
	<lastBuildDate>Tue, 22 Dec 2009 19:48:28 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How To Create Twitter Lists Automatically With PHP</title>
		<link>http://www.smmguru.com/2009/12/22/how-to-create-twitter-lists-automatically-with-php</link>
		<comments>http://www.smmguru.com/2009/12/22/how-to-create-twitter-lists-automatically-with-php#comments</comments>
		<pubDate>Tue, 22 Dec 2009 19:48:28 +0000</pubDate>
		<dc:creator>Tyler</dc:creator>
				<category><![CDATA[Social Media Marketing]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[TwitterBot]]></category>
		<category><![CDATA[Twitter Lists API]]></category>

		<guid isPermaLink="false">http://www.smmguru.com/?p=609</guid>
		<description><![CDATA[A regularly requested feature by a lot of my readers for Twitter Bot Script, and other tools has been the automatic creation of Twitter Lists. Meaning that you do not have to get user ID&#8217;s or anything&#8230; Just type in a title, enter your user names, and press make list, and it works.
This is actually [...]]]></description>
			<content:encoded><![CDATA[<p>A regularly requested feature by a lot of my readers for Twitter Bot Script, and other tools has been the automatic creation of Twitter Lists. Meaning that you do not have to get user ID&#8217;s or anything&#8230; Just type in a title, enter your user names, and press make list, and it works.</p>
<p>This is actually very easy to accomplish with a little PHP. You can download the script (free of course) <a href="http://twitterbotscript.com/showthread.php?t=5">from here</a> at the Twitter Bot Script forum.</p>
<p>Keep in mind that most people only get 150 API calls per hour on their account. The only way to add people to a list through the API as of right now is to use their Twitter account ID number. So you have 1 API call to create the list, 1 API call to get the user ID automatically, and then a third API call to add them to the list. (Way to go Twitter.) This means that you can create a list with up to 74 people on it, and add people to that list at a rate of 75 an hour. Keep in mind each user is limited to creating 20 lists each with a max of 500 users. That&#8217;s room for 10,000 accounts that suggest authority and influence Muahaha.</p>
<p>Use this script wisely they are getting smarter at Twitter&#8230; Updated version on the way that will allow you to use either user ID&#8217;s if you have them cutting API calls to 1 request per user on the list allowing you to add 149 at creation.</p>
<p>I also recommend storing your created lists in a MySQL database or something as a way of tracking / managing them from your toolkit. For instance when you get the 200 OK status back from creating the list, it also returns all the xml data for it. Store that in a row so you can keep track of what you have made, and make it easy to build up.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.smmguru.com/2009/12/22/how-to-create-twitter-lists-automatically-with-php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Twitter Bot Script &#8211; A Full Blown Bot Package</title>
		<link>http://www.smmguru.com/2009/06/27/twitter-bot-script-a-full-blown-bot-package</link>
		<comments>http://www.smmguru.com/2009/06/27/twitter-bot-script-a-full-blown-bot-package#comments</comments>
		<pubDate>Sat, 27 Jun 2009 18:26:05 +0000</pubDate>
		<dc:creator>Tyler</dc:creator>
				<category><![CDATA[Twitter]]></category>
		<category><![CDATA[TwitterBot]]></category>
		<category><![CDATA[TBS]]></category>
		<category><![CDATA[Twitter Bot Script]]></category>

		<guid isPermaLink="false">http://www.smmguru.com/?p=589</guid>
		<description><![CDATA[A few months ago I did a post about how to make a Twitter bot with php. The post is currently ranking number one for making a Twitter bot and I was getting tons of emails on tyler.tc on how to make the script more functional, and basically just do more. I put some ideas [...]]]></description>
			<content:encoded><![CDATA[<p>A few months ago I did a post about <a href="http://www.smmguru.com/2008/10/31/how-to-make-a-twitter-bot-with-php-in-five-minuets" target="_blank">how to make a Twitter bot with php</a>. The post is currently <a href="http://www.google.com/search?rlz=1C1CHMG_enUS291US303&amp;sourceid=chrome&amp;ie=UTF-8&amp;q=make+a+twitter+bot" target="_blank">ranking number one</a> for making a Twitter bot and I was getting tons of emails on tyler.tc on how to make the script more functional, and basically just do more. I put some ideas down and sent them to a few friends and got a great response. After putting some code together and releasing it online, TwitterBotScript or &#8220;TBS&#8221; has become a hit.</p>
<p>The reason being: Its simple to use, its constantly evolving, it allows you to expand your Twitter account (and marketing efforts) <strong>extremely fast</strong>, and its <strong>FREE</strong>. Think of TBS as an open source twitter bot script. Not only can you download it but its easy to build on with your own ideas and a little PHP experience.</p>
<p><a href="http://twitterbotscript.com/" target="_blank">Twitter Bot Script</a> comes with what has been dubbed the TBS Toolkit, lets look at some features:</p>
<ul>
<li><strong>Full GUI</strong> tweet management including &#8220;Show Status&#8221; which allows you to pause that tweet from appearing in your activities.</li>
<li><strong>Import tweets via a CSV file</strong> with the ability to set their status and type on the fly.</li>
<li>Create globally used tweets, or create special tweets to be used only for replies and direct messages.</li>
<li>The <strong>Mention Reply Tool</strong> will allow you to see all the recent @your tweets and automatically respond to them using the bulk responder option, or quickly write up a custom response. TBS will also keep track of the tweets you respond to so you don&#8217;t continually send duplicate responses like with other bot scripts.</li>
<li>The <strong>Make Friends Tool</strong> is another awesome tool only available from TwitterBotScript. This tool will give you a bunch of new ways to make friends on Twitter. Account sourcing will allow you to randomly follow users from your friends or followers (toggle) while allowing you to reselect the target, and the required amount of followers for each person you try to follow on the fly. You can also find new friends via keyword searching, or by directly inputting lists of user names.</li>
<li>TBS of course includes a <strong>status update tool </strong>that works just like your Twitter homepage.</li>
<li><strong>Sleep Mode </strong>will allow you to randomize the time at which your tweets appear on Twitter. When you automate with CRON, your script is run at the same time interval every time. By using sleep mode, the script will essentially sleep for a random amount of time making your tweeting look more natural to Twitter users.</li>
<li><strong>Tweet counter</strong>. So lets say you don&#8217;t have a larger number of tweets to work with and you don&#8217;t want to keep repeating them. You can globally set a tweet limit in TwitterBotScript limiting the number of times each message can be used.</li>
<li><strong>API Rate Limiting integration</strong>.</li>
</ul>
<p>Another bonus is Twitter bot script <strong>requires almost nothing to run.</strong>.. A basic installation of Apache, MySQL, and PHP (and cURL of course) will do the job. But you will need CRON in order to use automation. In the next release, Twitter Bot Script will have a synthetic version of CRON like what WordPress uses.</p>
<p><a href="http://twitterbotscript.com" target="_blank">Twitter Bot Script</a> has been installed <strong>598 times since it was released four days ago</strong>. I think with a little push Twitter Bot Script could easily become the king. I looked around today at the competition and most of the stuff out there is either very basic or very expensive.  This puts Twitter Bot Script at a distinct advantage as users get an advanced tool set that is constantly seeing additions and revisions, for free. Yeah, there is definitely work to be done but that&#8217;s the point. As I get more and more emails for I&#8217;ll know what direction to move in.</p>
<p>So go <a href="http://twitterbotscript.com" target="_blank">download Twitter Bot Script</a> and play around with it. You don&#8217;t have to be marketing your Micheal Jackson t-shirts to have fun with Twitter Bot Script. Its great for easily finding new friends and exposure.</p>
<p>Also: If your handy with PHP and working with APIs, <a href="http://tyler.tc/portfolio/contact.html" target="_blank">shoot me an email</a> if your interested in working on this project.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.smmguru.com/2009/06/27/twitter-bot-script-a-full-blown-bot-package/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Expanding On TwitterBot &#8211; Keep Track of Used Tweets</title>
		<link>http://www.smmguru.com/2008/11/03/expanding-on-twitterbot-keep-track-of-used-tweets</link>
		<comments>http://www.smmguru.com/2008/11/03/expanding-on-twitterbot-keep-track-of-used-tweets#comments</comments>
		<pubDate>Mon, 03 Nov 2008 18:30:48 +0000</pubDate>
		<dc:creator>Tyler</dc:creator>
				<category><![CDATA[Resources]]></category>
		<category><![CDATA[Social Media]]></category>
		<category><![CDATA[Social Media Marketing]]></category>
		<category><![CDATA[TwitterBot]]></category>
		<category><![CDATA[bots]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://www.smmguru.com/?p=467</guid>
		<description><![CDATA[Now that you know how to make a Twitter bot you may be looking to add some more functionality to it. One problem you may run into after some time is that you keep recycling or re-sending the same messages to Twitter. For example, you have 100 facts about your self and you don&#8217;t want [...]]]></description>
			<content:encoded><![CDATA[<p>Now that you know <a href="http://www.smmguru.com/2008/10/31/how-to-make-a-twitter-bot-with-php-in-five-minuets" target="_blank">how to make a Twitter bot</a> you may be looking to add some more functionality to it. One problem you may run into after some time is that you keep recycling or re-sending the same messages to Twitter. For example, you have 100 facts about your self and you don&#8217;t want any of them to appear twice but you want everything to be automated. How do you do this? Easy, just add a status field to your `tweets` table.</p>
<p><strong>Step 1 &#8211; Add the field.</strong><br />
To add the field you can use the simple graphical interface in phpMyAdmin or use the SQL tab (or alternative) to run this code:</p>
<p>ALTER TABLE `tweets` ADD `status` VARCHAR(10) NOT NULL;</p>
<p>What this will do is create a new field in your tweets table with 10 characters of space for that messages status. We will be setting them all to &#8220;ready&#8221;, and later changing our PHP code to update them as we go along.</p>
<p><strong>Step 2 &#8211; Set all tweets to ready.</strong><br />
After you have the new field added to your database you will need to set all of the tweets you want to use to &#8216;ready&#8217; status. In this example, only tweets with the status set to &#8216;ready&#8217; can be randomly selected.</p>
<p>While inside of phpMyAdmin (SQL tab) or what ever tool you use, go to the page that allows you to run MySQL commands on your tables and enter this code:</p>
<p>UPDATE `tweets` SET `status` = &#8216;ready&#8217;</p>
<p>Alternatively you can pick which ones you want to use if you already have some tweets that you wish not to recycle. This SQL command will update every tweet/message you have in your database so use it wisely.</p>
<p><strong>Step 3 &#8211; Modify PHP to update tweet status in database.</strong><br />
Our third an final step is to modify the php script so it will change the status of every used tweet. To do this, we will make a few simple changes to our original code.</p>
<p>First off, we have to change the MySQL query so it will only pull random messages with &#8220;ready&#8221; status:</p>
<div class="php php" style="font-family:monospace;color: #006; padding:8px; background-color: #f0f0f0;"><span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <a style="color: #000060;" href="http://www.php.net/mysql_query"><span style="color: #990000;">mysql_query</span></a> <span style="color: #009900;">(</span>“SELECT <span style="color: #339933;">*</span> FROM tweets WHERE status <span style="color: #339933;">=</span> <span>&#8216;ready&#8217;</span> ORDER BY <a style="color: #000060;" href="http://www.php.net/rand"><span style="color: #990000;">RAND</span></a><span style="color: #009900;">(</span><span style="color: #009900;">)</span> LIMIT <span style="color: #cc66cc;">1</span><span style="font-style: italic; color: #666666;">);</span></div>
<p>For our second change, we will need to get the ID number of the tweet from the database and pass it to the sendTweet() function we will modify in a moment:</p>
<div class="php php" style="font-family:monospace;color: #006; padding:8px; background-color: #f0f0f0;"><span style="color: #b1b100;">while</span><span style="color: #009900;">(</span><span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <a style="color: #000060;" href="http://www.php.net/mysql_fetch_array"><span style="color: #990000;">mysql_fetch_array</span></a><span style="color: #009900;">(</span><span style="color: #000088;">$result</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #009900;">{</span></p>
<p><span style="color: #000088;">$tweet</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&#8220;$row[tweet]&#8220;</span>;</p>
<p><span style="color: #000088;">$tweetID</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&#8220;$row[id]&#8220;</span>;</p>
<p>sendTweet<span style="color: #009900;">(</span><span style="color: #000088;">$tweet</span><span style="color: #339933;">,</span> <span style="color: #000088;">$tweetID</span><span style="color: #009900;">)</span>;</p>
<p><span style="color: #009900;">}</span></div>
<p>Then we modify our sendTweet() function to handle the tweet&#8217;s ID, and then change its status if the message is successfully sent to Twitter:</p>
<div class="php php" style="font-family:monospace;color: #006;padding:8px; background-color: #f0f0f0;"><span style="font-weight: bold; color: #000000;">function</span> sendTweet<span style="color: #009900;">(</span><span style="color: #000088;">$msg</span><span style="color: #339933;">,</span> <span style="color: #000088;">$idoftweet</span><span style="color: #009900;">)</span><span style="color: #009900;">{</span></p>
<p><span style="color: #000088;">$username</span> <span style="color: #339933;">=</span> ‘TWITTER<span style="color: #339933;">-</span>USER<span style="color: #339933;">-</span>NAME’;</p>
<p><span style="color: #000088;">$password</span> <span style="color: #339933;">=</span> ‘TWITTER<span style="color: #339933;">-</span>PASS’;</p>
<p><span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> ‘http<span style="color: #339933;">:</span><span style="font-style: italic; color: #666666;">//twitter.com/statuses/update.xml’;</span></p>
<p><span style="color: #000088;">$curl_handle</span> <span style="color: #339933;">=</span> curl_init<span style="color: #009900;">(</span><span style="color: #009900;">)</span>;</p>
<p>curl_setopt<span style="color: #009900;">(</span><span style="color: #000088;">$curl_handle</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> “<span style="color: #000088;">$url</span>”<span style="color: #009900;">)</span>;</p>
<p>curl_setopt<span style="color: #009900;">(</span><span style="color: #000088;">$curl_handle</span><span style="color: #339933;">,</span> CURLOPT_CONNECTTIMEOUT<span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">)</span>;</p>
<p>curl_setopt<span style="color: #009900;">(</span><span style="color: #000088;">$curl_handle</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">)</span>;</p>
<p>curl_setopt<span style="color: #009900;">(</span><span style="color: #000088;">$curl_handle</span><span style="color: #339933;">,</span> CURLOPT_POST<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">)</span>;</p>
<p>curl_setopt<span style="color: #009900;">(</span><span style="color: #000088;">$curl_handle</span><span style="color: #339933;">,</span> CURLOPT_POSTFIELDS<span style="color: #339933;">,</span> “status<span style="color: #339933;">=</span><span style="color: #000088;">$msg</span>”<span style="color: #009900;">)</span>;</p>
<p>curl_setopt<span style="color: #009900;">(</span><span style="color: #000088;">$curl_handle</span><span style="color: #339933;">,</span> CURLOPT_USERPWD<span style="color: #339933;">,</span> “<span style="color: #000088;">$username</span><span style="color: #339933;">:</span><span style="color: #000088;">$password</span>”<span style="color: #009900;">)</span>;</p>
<p><span style="color: #000088;">$buffer</span> <span style="color: #339933;">=</span> curl_exec<span style="color: #009900;">(</span><span style="color: #000088;">$curl_handle</span><span style="color: #009900;">)</span>;</p>
<p>curl_close<span style="color: #009900;">(</span><span style="color: #000088;">$curl_handle</span><span style="color: #009900;">)</span>;</p>
<p><span style="color: #b1b100;">if</span> <span style="color: #009900;">(</span><a style="color: #000060;" href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">(</span><span style="color: #000088;">$buffer</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span></p>
<p><a style="color: #000060;" href="http://www.php.net/echo"><span style="color: #990000;">echo</span></a> ‘fail’;</p>
<p><span style="color: #009900;">}</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">{</span></p>
<p><a style="color: #000060;" href="http://www.php.net/echo"><span style="color: #990000;">echo</span></a> ’success’;</p>
<p><a style="color: #000060;" href="http://www.php.net/mysql_query"><span style="color: #990000;">mysql_query</span></a><span style="color: #009900;">(</span><span style="color: #0000ff;">&#8220;UPDATE `tweets` SET `status` = &#8216;used&#8217; WHERE id = &#8216;$idoftweet&#8217;&#8221;</span><span style="color: #009900;">)</span>;</p>
<p><span style="color: #009900;">}</span></div>
<p>Now it&#8217;s all ready to role. Now every time a message is pulled from the database and sent to Twitter (successfully) it will have it&#8217;s status changed to &#8220;used&#8221; taking it out of the possible messages to send. Just upload your new php file, re-activate your CRON job and have some fun.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.smmguru.com/2008/11/03/expanding-on-twitterbot-keep-track-of-used-tweets/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Make A Twitter Bot With PHP In Five Minutes</title>
		<link>http://www.smmguru.com/2008/10/31/how-to-make-a-twitter-bot-with-php-in-five-minuets</link>
		<comments>http://www.smmguru.com/2008/10/31/how-to-make-a-twitter-bot-with-php-in-five-minuets#comments</comments>
		<pubDate>Fri, 31 Oct 2008 17:41:28 +0000</pubDate>
		<dc:creator>Tyler</dc:creator>
				<category><![CDATA[Resources]]></category>
		<category><![CDATA[Social Media]]></category>
		<category><![CDATA[Social Media Marketing]]></category>
		<category><![CDATA[TwitterBot]]></category>
		<category><![CDATA[bots]]></category>
		<category><![CDATA[smm]]></category>
		<category><![CDATA[SMO]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://www.smmguru.com/?p=461</guid>
		<description><![CDATA[
There are quite a few uses I could think of for an automated Twitter bot that posts new tweets for you throughout the day. While this sounds like it would be a hard task it&#8217;s actually quite easy and a great project for anyone who wants to learn how to use the Twitter API within [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-470" style="float:left; margin:0 10px 0 0;" title="twitterbot" src="http://www.smmguru.com/wp-content/uploads/2008/10/twitterbot.png" alt="" width="153" height="153" /></p>
<p>There are quite a few uses I could think of for an automated Twitter bot that posts new tweets for you throughout the day. While this sounds like it would be a hard task it&#8217;s actually quite easy and a great project for anyone who wants to learn how to use the Twitter API within PHP. Lets get started.</p>
<p><strong>Step 1 &#8211; Create your database.</strong></p>
<p>When creating your database there are a number of things you may want to think of ahead of time. For the sake of making things easy I chose to tone down the code I use and show you how it works. We will create a simple table to store all of the random tweets in.</p>
<div class="mysql mysql" style="font-family:monospace;color: #006; padding:8px; background-color: #f0f0f0;"><span style="font-weight: bold; color: #993333;">CREATE TABLE</span> `tweets` <span style="color: #66cc66;">(</span></p>
<p>`id` <span style="font-weight: bold; color: #aa9933;">INT</span><span style="color: #66cc66;">(</span><span style="color: #cc66cc;">11</span><span style="color: #66cc66;">)</span> <span style="font-weight: bold; color: #aa3399;">NOT NULL</span> <span style="font-weight: bold; color: #aa3399;">AUTO_INCREMENT</span>,</p>
<p>`tweet` <span style="font-weight: bold; color: #aa9933;">VARCHAR</span><span style="color: #66cc66;">(</span><span style="color: #cc66cc;">140</span><span style="color: #66cc66;">)</span> <span style="font-weight: bold; color: #aa3399;">DEFAULT</span> <span style="font-weight: bold; color: #aa3399;">NULL</span>,</p>
<p><span style="font-weight: bold; color: #993333;">PRIMARY KEY</span> <span style="color: #66cc66;">(</span>`id`<span style="color: #66cc66;">)</span></p>
<p><span style="color: #66cc66;">)</span></div>
<p>Run that SQL and you should have a new &#8220;tweets&#8221; table in your chosen database. Notice how we limited the `tweet` field to 140 characters as well so we don&#8217;t have tweets that are too long to appear on Twitter.</p>
<p><strong>Step 2 &#8211; Create the PHP to send the tweet.</strong></p>
<p>The next step is to create a php script that will randomly select one of your tweets, and then send it to your Twitter account via Twitter&#8217;s API. While this sounds complicated, its very easy to do.</p>
<div class="php php" style="font-family:monospace;color: #006; padding:8px; background-color: #f0f0f0;"><span style="font-weight: bold; color: #000000;">&lt;?php</span></p>
<p><a style="color: #000060;" href="http://www.php.net/mysql_connect"><span style="color: #990000;">mysql_connect</span></a><span style="color: #009900;">(</span><span style="color: #0000ff;">&#8220;localhost&#8221;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&#8220;USERNAME&#8221;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&#8220;PASSWORD&#8221;</span><span style="color: #009900;">)</span> or <a style="color: #000060;" href="http://www.php.net/die"><span style="color: #990000;">die</span></a><span style="color: #009900;">(</span><span>&#8216;Could not connect to database&#8217;</span><span style="color: #009900;">)</span>;</p>
<p><a style="color: #000060;" href="http://www.php.net/mysql_select_db"><span style="color: #990000;">mysql_select_db</span></a><span style="color: #009900;">(</span><span style="color: #0000ff;">&#8220;DATABASE&#8221;</span><span style="color: #009900;">)</span> or <a style="color: #000060;" href="http://www.php.net/die"><span style="color: #990000;">die</span></a><span style="color: #009900;">(</span><span>&#8216;Could not select database&#8217;</span><span style="color: #009900;">)</span>;</p>
<p><span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <a style="color: #000060;" href="http://www.php.net/mysql_query"><span style="color: #990000;">mysql_query</span></a> <span style="color: #009900;">(</span><span style="color: #0000ff;">&#8220;SELECT * FROM tweets ORDER BY RAND() LIMIT 1&#8243;</span><span style="color: #009900;">)</span>;</p>
<p><span style="color: #b1b100;">while</span><span style="color: #009900;">(</span><span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <a style="color: #000060;" href="http://www.php.net/mysql_fetch_array"><span style="color: #990000;">mysql_fetch_array</span></a><span style="color: #009900;">(</span><span style="color: #000088;">$result</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #009900;">{</span></p>
<p><span style="color: #000088;">$tweet</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&#8220;$row[tweet]&#8220;</span>;</p>
<p>sendTweet<span style="color: #009900;">(</span><span style="color: #000088;">$tweet</span><span style="color: #009900;">)</span>;</p>
<p><span style="color: #009900;">}</span></p>
<p><span style="font-weight: bold; color: #000000;">function</span> sendTweet<span style="color: #009900;">(</span><span style="color: #000088;">$msg</span><span style="color: #009900;">)</span><span style="color: #009900;">{</span></p>
<p><span style="color: #000088;">$username</span> <span style="color: #339933;">=</span> <span>&#8216;TWITTER-USER-NAME&#8217;</span>;</p>
<p><span style="color: #000088;">$password</span> <span style="color: #339933;">=</span> <span>&#8216;TWITTER-PASS&#8217;</span>;</p>
<p><span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span>&#8216;http://twitter.com/statuses/update.xml&#8217;</span>;</p>
<p><span style="color: #000088;">$curl_handle</span> <span style="color: #339933;">=</span> curl_init<span style="color: #009900;">(</span><span style="color: #009900;">)</span>;</p>
<p>curl_setopt<span style="color: #009900;">(</span><span style="color: #000088;">$curl_handle</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #0000ff;">&#8220;$url&#8221;</span><span style="color: #009900;">)</span>;</p>
<p>curl_setopt<span style="color: #009900;">(</span><span style="color: #000088;">$curl_handle</span><span style="color: #339933;">,</span> CURLOPT_CONNECTTIMEOUT<span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">)</span>;</p>
<p>curl_setopt<span style="color: #009900;">(</span><span style="color: #000088;">$curl_handle</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">)</span>;</p>
<p>curl_setopt<span style="color: #009900;">(</span><span style="color: #000088;">$curl_handle</span><span style="color: #339933;">,</span> CURLOPT_POST<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">)</span>;</p>
<p>curl_setopt<span style="color: #009900;">(</span><span style="color: #000088;">$curl_handle</span><span style="color: #339933;">,</span> CURLOPT_POSTFIELDS<span style="color: #339933;">,</span> <span style="color: #0000ff;">&#8220;status=$msg&#8221;</span><span style="color: #009900;">)</span>;</p>
<p>curl_setopt<span style="color: #009900;">(</span><span style="color: #000088;">$curl_handle</span><span style="color: #339933;">,</span> CURLOPT_USERPWD<span style="color: #339933;">,</span> <span style="color: #0000ff;">&#8220;$username:$password&#8221;</span><span style="color: #009900;">)</span>;</p>
<p><span style="color: #000088;">$buffer</span> <span style="color: #339933;">=</span> curl_exec<span style="color: #009900;">(</span><span style="color: #000088;">$curl_handle</span><span style="color: #009900;">)</span>;</p>
<p>curl_close<span style="color: #009900;">(</span><span style="color: #000088;">$curl_handle</span><span style="color: #009900;">)</span>;</p>
<p><span style="color: #b1b100;">if</span> <span style="color: #009900;">(</span><a style="color: #000060;" href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">(</span><span style="color: #000088;">$buffer</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span></p>
<p><a style="color: #000060;" href="http://www.php.net/echo"><span style="color: #990000;">echo</span></a> <span>&#8216;fail&#8217;</span>;</p>
<p><span style="color: #009900;">}</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">{</span></p>
<p><a style="color: #000060;" href="http://www.php.net/echo"><span style="color: #990000;">echo</span></a> <span>&#8217;success&#8217;</span>;</p>
<p><span style="color: #009900;">}</span></p>
<p><span style="color: #009900;">}</span></p>
<p><span style="font-weight: bold; color: #000000;">?&gt;</span></div>
<p>Not to bad right? Our custom sendTweet() function pretty much takes care of all the dirty work in sending the message to Twitter. Just <strong>make sure you edit the code</strong> with your password and username for Twitter, and the MySQL login. Once you have your database populated you are all good to go and test the script to see if it works. Just upload it, run it, and you should see either &#8220;fail&#8221; or &#8220;success&#8221; on your screen.</p>
<p><strong>Step 3 &#8211; Automate with CRON.</strong></p>
<p>After going to Twitter and checking your account to confirm everything is copacetic, it&#8217;s time to let your monster loose. Depending on what host you use, CRON access may or may not be available to you. Luckily for me I am hosted with <a href="http://www.mediatemple.com" target="_blank">MediaTemple</a> so this is not a problem.</p>
<ul>
<li><strong>Script Location -</strong> When using CRON you normally want to upload the file being run into a folder that nobody has access to from the web (root). After you have it in this location, just plug it into CRON with &#8216;php&#8217; in front of it. Example: php /home/user/root/TwitterBot.php</li>
<li><strong>Set The Time -</strong> I don&#8217;t think I have ever used a control panel that required you to manually enter the time format&#8230; I&#8217;m pretty sure most people use cPanel which also has drop downs to select when you would like the script to run. I like to run my Twitter bot every 25 minuets or so to keep my Twitter account fresh.</li>
</ul>
<p>That&#8217;s it! Not to hard right&#8230; If you have any in-depth questions on the code or need help, feel free to leave a comment. Also leave one if you have usage ideas, new features that could make the script better. As you can now see, this is a valuable tool to have in your chest.</p>
<p><strong>UPDATE 5/8/2009</strong></p>
<p>I have released a full blown version of the script packed with features and a complete backend GUI. This has proven to be a great Twitter marketing too! Unlike all the others, I support mine and its not a billion dollars. Check out the site for all the details.</p>
<p><a href="http://twitterbotscript.com" target="_blank">Get Twitterbotscript now!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.smmguru.com/2008/10/31/how-to-make-a-twitter-bot-with-php-in-five-minuets/feed</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
	</channel>
</rss>
