example of how to get the ID
$url = "http://search.twitter.com/search.json?q=QUERY"; //<--- replace the word QUERY for your own query
$data = get_data($url);
$obj = json_decode($data);
function get_data($url){
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
foreach ($obj->results as $item){
$text = $item->text;
$user = $item-> from_user;
$img = $item->profile_image_url;
$tweetId = $item->id_str; // <--- On this line we are getting the ID of the tweet
echo ' @';
echo $user;
echo $text;
echo 'Tweet ID: '. $tweetId; //<-- On this line we display the ID of the tweet
For more information GET search | Twitter Developers
The example request on the line 30 shows "id_str":"122032448266698752"
and thats the reason of use $tweetId = $item->id_str;
to get the id_str