I am using the reference from Inserting data from Twitter API into a MySQL Database using php to insert tweets into mysql database. But i am getting PHP "Fatal error: Uncaught mysqli_sql_exception: Column 'id_str' cannot be null". Even if I use another variable like 'created_at', I am getting the same error.
Is it because the json is not properly parsed? Below is the code snippet:
$twitter = new TwitterAPIExchange($settings);
$url = 'https://api.twitter.com/1.1/search/tweets.json';
$getfield = '?q='.urlencode("#f1").'&count=10'.'&tweet_mode=extended';
$requestMethod = 'GET';
$tweets = json_decode($twitter->setGetfield($getfield)->buildOauth($url, $requestMethod)->performRequest(),$assoc = TRUE);
foreach($tweets as $tweet){
$created_at = $tweet['created_at'];
$id_str = $tweet['id_str'];
<PHP PREPARED STATEMENTs FOR INSERTING etc>
}