forked from romulcah/tmr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
send.php
34 lines (20 loc) · 788 Bytes
/
send.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
<?php
require "twitteroauth/autoload.php";
include("config.php");
include("db.php");
$database = new Database();
use Abraham\TwitterOAuth\TwitterOAuth;
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
$database->query('SELECT id,tweet,tweet_id from tweets WHERE sent=0');
$rows = $database->resultset();
$database->beginTransaction();
$database->query('UPDATE tweets SET sent = 1 where id = :id');
foreach($rows as $tweet){
$result = $connection->post('statuses/update', array('in_reply_to_status_id'=> $tweet['tweet_id'] ,'status' =>$tweet['tweet']));
print_r($result);
if($result->id > 0){
$database->bind(':id', $tweet['id']);
$database->execute();
}
}
$database->endTransaction();