-
Notifications
You must be signed in to change notification settings - Fork 7
/
bot.php
44 lines (33 loc) · 1.08 KB
/
bot.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
error_reporting(-1);
require "vendor/autoload.php";
include 'credentials.php';
use Abraham\TwitterOAuth\TwitterOAuth;
use Analog\Analog;
ini_set('memory_limit', '2048M');
$log_file = 'bot.log';
Analog::handler (Analog\Handler\File::init ($log_file));
function search(array $query){
global $connection;
return $connection->get('search/tweets', $query);
}
$connection = new TwitterOAuth($consumer_key, $consumer_secret, $access_key, $access_secret);
$query = array(
'q' => 'bosanac OR bosanci OR bosancu OR bosanca OR bosanaca OR bosancima OR bosance',
'count' => '20',
'result_type' => 'recent'
);
$results = search($query);
foreach ($results->statuses as $result) {
$text = $result->text;
$user = $result->user->screen_name;
$newtweet = "bošnjak*";
$replyuser = "@" . $user ;
$reply = "$replyuser $newtweet";
echo $reply . "\n";
$tweetID = $result->id_str;
Analog::log('{$reply} to Tweet: $text \n');
//Reply to tweet
$response = $connection->post('statuses/update' , array('status' => $reply, 'in_reply_to_status_id' => $result->id_str));
}
?>