forked from philipbeel/Tweetable
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
32 lines (32 loc) · 902 Bytes
/
index.php
File metadata and controls
32 lines (32 loc) · 902 Bytes
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
<?php
require "twitter/autoload.php";
$CONSUMER_KEY='Your Consumer key';
$CONSUMER_SECRET='Your Consumer Secret';
$accessToken='Your access Token';
$accessTokenSecret='Your Secret access Token';
$id=$_GET['screen_name'];
$limit=$_GET['limit'];
use Abraham\TwitterOAuth\TwitterOAuth;
$connection = new TwitterOAuth($CONSUMER_KEY, $CONSUMER_SECRET, $accessToken, $accessTokenSecret);
$twitterData = $connection->get(
'statuses/home_timeline',
array(
'screen_name' => $id,
'count' => $limit
)
);
$tweets=array();
$i=0;
if(!empty($twitterData)){
foreach($twitterData as $tweet){
if (!empty($tweet->id))
{
$tweets[$i]['tweet_date']=date("YM d H:i:sTZY",strtotime($tweet->created_at));
$tweets[$i]['response']=$tweet->text;
$i++;
}
}
}
$result['tweets']=$tweets;
echo json_encode($result);
?>