Hello all.
I’m very new at web development and such in order to learn something new I have set myself a challenge of learning some PHP, JSON MySql etc.
So far I have managed to get a JSON feed for a certain mention, however this brings back many records from ages back, reading the twitter API I should be able to pass the since argument so that I can only pull back results say in the past 24 hours. but I cant get it to work.
Here is the working code which pulls back all mentions…
<?php
// This is the mention I'm looking for in the return twitter JSON feed
$search = "@timberners_lee";
// The Number of tweets I want to capture
$notweets = 2;
$tweets = $connection->get("https://api.twitter.com/1.1/search/tweets.json?q=".$search."&count=".$notweets;
?>
I have modified the above code to read…
<?php
// This is the mention I'm looking for in the return twitter JSON feed
$search = "@timberners_lee";
// The Number of tweets I want to capture
$notweets = 2;
// The Date
$querydate = new DateTime();
$querydate = $querydate->format('Y-m-d');
$tweets = $connection->get("https://api.twitter.com/1.1/search/tweets.json?q=".$search."&count=".$notweets."&since=".$querydate);
?>
I’m getting the following error message…
Call to a member function format() on a non-object
Any help greatly appreciated…