php Local Twitter Trends Finder
<?php
$ConsumerKeyAPIKey="YOUR CONSUMER KEY WILL BE HERE";
$ConsumerSecretAPISecret="YOUR SECRET KEY WILL BE HERE";
$NumberOfTags=5; //keep as minimum as possible
$GeoLocleID="20070458";
require "twitteroauth/autoload.php";
use Abraham\TwitterOAuth\TwitterOAuth;
$connection = new TwitterOAuth($ConsumerKeyAPIKey, $ConsumerSecretAPISecret, $access_token, $access_token_secret);
$statues = $connection->get("trends/place", ["id" => $GeoLocleID]);
$stringgerr="";
$i=1;
foreach($statues as $hash)
{ $inner=$hash->trends;
foreach($inner as $in)
{
$value=$in->name;
if (strpos($value, '#') !== false) {
$value=$value;
} else {
$value="#".$value;
}
$stringgerr.=str_replace(" ","_",$value)." ";
if($i==$NumberOfTags)
break;
$i++;
}
if($i==$NumberOfTags)
break;
}
echo $stringgerr;