<?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; bots</title>
	<atom:link href="http://www.smmguru.com/tag/bots/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>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>
