Skip to content

amanelis/zoonika

Repository files navigation

CUZTbot Example

Example app using this program: z2.zootzy.com/ztbot/ type files according to path

Installation

To configure, first edit config/config.inc.php, 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: help.twitter.com/entries/15364

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
require_once("config/config.inc.php");

//include the dom class
require_once("classes/dom.class.php");

//include twitter api class
require_once("classes/twit.class.php");

//include the twitter API
require_once("functions/twitter.standard.php");

//include the scrapper class
require_once('functions/scrape.php');

//include the sentiment analysis class
require_once('functions/sentiment.php');
/*************************************/

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.

sendTweets($search);

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

sendTweets($search_term);

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], 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).

About

My research repository for ztbot, a more advanced implementation.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published