geocode( $location );
if ( ! $coordinates ) {
return;
}
$latitude = $coordinates->getLatitude();
$longitude = $coordinates->getLongitude();
$radius = 50; // Set the radius in kilometers
$tweet_query = new TweetQuery();
$tweet_query->setGeocode( $latitude, $longitude, $radius );
$tweet_query->setUntil( date( 'Y-m-d' ) );
$tweet_query->setResultType( 'recent' );
$tweet_query->setCount( 10 ); // Set the number of tweets to display
$tweet_service = new TweetService( new TwitterOAuth( CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET ) );
$tweets = $tweet_service->search( $tweet_query );
if ( empty( $tweets ) ) {
return;
}
echo '
- ';
foreach ( $tweets as $tweet ) {
$tweet_text = $tweet->getText();
$tweet_date = $tweet->getCreatedAt();
echo '
- ';
echo '
' . $tweet_text . '
'; echo '' .