Skip to content


Subversion checkout URL

You can clone with
Download ZIP
My research repository for ztbot, a more advanced implementation
PHP JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.


CUZTbot Example

Example app using this program: type files according to path


To configure, first edit config/, this file will contain your bots username/password, change this to yours. Next few lines contain your database information, enter this in, will be used later on.

Basic USAGE - Teabot

To invoke the twitter bot there are several tasks that must be setup. First if you will be running in cron, you must set a cron job to call this file every few minutes. You must be carefull as to how many times and tweets you actually output do to twitter status update limits. That information can be found here:

1)Includes you must have. If you look in the root at ztbot.php you will see the files need to use the bot.

//////////MUST INCLUDE TO WORK/////////
//include config file

//include the dom class

//include twitter api class

//include the twitter API

//include the scrapper class

//include the sentiment analysis class

2) To start using the twitter bot (Teabot) open the ztbot.php file in the root of the app and edit line 21. Change the search term to whatever you want your bot to watch for.

$search = 'tea';

3) Just below this line on 22, you will see there is a function call to sendTweets(param = your search term). This function (kind of self explanatory), will take your search term (as defined on line 21), and will look in either your database for tweet responses.


4) Your output will display your Twitter Bot's name, date/time, your response to the users tweet. All the data will be outputted per line. At the bottom will display your search term, and API calls for the hour left.

Basic Functions

With the twitter bot, you are given plenty of functions to do anything a regular twitter use can do.

1) Follow user. Params: String, twitter username. File: functions/scrape.php

function Follow_User($screen_name);

2) Recent Metions/Reply. Params: String, twitter username. File: functions/scrape.php

function recent_mentions_reply($login);

3) Twitter User Information. Params: String, twitter username. File functions/scrape.php

function twitterUserInformation($user);

4) Send Tweets. Params: String, search term you want to respond to. File function/scrape.php


Basic USAGE - Sentiment Analysis

1) To invoke the sentiment analysis functions to analyze tweets (or sentences of your choice) simply follow the code below in the sent.php file in the root. To start with this code. You first choose a search term. Specify how many results you want to return. The max I believe is 150 from the API limit. The third line in this snippet searches the twitter stream by means of returning a two dimensional array of [tweet result #] -> [user][tweet], this can easily be parsed by the foreach loop, then passing that data to sentiment analysis function.

$search = 'avatar';
$result = 100;
$search_output = twitter_search($search, $result);

foreach ($search_output as $term){
        sentimentAnalysis_1($term[tweet], $search);

2)Output will display the tweet, process time, how many words it did an analysis on, and finally the result: pos, neg, neu depending on what the analysis concludes. The main sentimentAnalysis_1() can be found in functions/sentiment.php. There will be more iterations of this function later on through development. In functions/sentiment.php you can also find some usefull array printing/parsing/tokenizing functions, that the sentimentAnalysis_1() heavily depends on to parse tweets(sentences).

Something went wrong with that request. Please try again.