Hey guys I am trying to get some tweets by using the twitter API but I get this error when I run it:
Trying to get property of non-object in C:\xampp\htdocs\final_app\search_tweets.php on line 26 (commented on the code which line it is.
Here is my code, can anyone give any suggestion?
<?php include "library/twitteroauth.php"; ?>
<?php
$consumer = "xx";
$consumersecret = "xx";
$accesstoken = "xx";
$accesstokensecret = "";
$twitter = new TwitterOAuth($consumer, $consumersecret, $accesstoken, $accesstokensecret);
?>
<html>
<head>
<meta charset="UTF-8" />
<title>Team 11 - Final App</title>
</head>
<body>
<form action ="" method="POST">
<label> Search : <input type="text" name="keyword"/></label>
</form>
<?php
if (isset($_POST['keyword'])){
$tweets = $twitter->get('https://api.twitter.com/1.1/search/tweets.json?q='.$_POST['keyword'].'&since_id=24012619984051000&max_id=250126199840518145&result_type=recent&count=50');
foreach($tweets as $tweet){
foreach($tweet as $t){
echo $t->text; //THIS IS LINE 26
}
}
}
?>
</body>