Hi all,
I need some help in using the Twitter API. first of all, i’m a beginner in Twitter API + PHP thing. Im using tmhOAuth as my learning ground.
My app is some sort of reporting tools, where i can search particular keyword and see how many RTs that a particular tweet got.
this is my coding
<?php
require 'class/tmhOAuth.php';
require 'class/tmhUtilities.php';
$tmhOAuth = new tmhOAuth(array());
$newClass = new tmhOAuth(array());
$pages=5;
$args = array('q' => $_GET[q],'since_id' => '0','rpp' => '100');
$i = 0;
$results = array();
for ($i=$pages; $i > 0; $i--) {
$args['page'] = $i;
$tmhOAuth->request('GET','http://search.twitter.com/search.json',$args,false);
if ($tmhOAuth->response['code'] == 200) {
$data = json_decode($tmhOAuth->response['response'], true);
$results = array_merge($results, $data['results']);
}
else {
echo 'Error';
break;
}
}
echo '<p style="color:brown">';
echo 'Search Term: '. stripslashes($_GET['q']);
echo '</p>';
foreach( $results as $result ){
$i++;
echo '<p><div id="tweets">';
echo '<p>'.$i.'</p> ';
echo '<div class="avatar"><img src="'. "{$result['profile_image_url']}". '" /> </div>';
echo '<div class="twitcont">';
echo '<div class="name">'. "@<a href='http://twitter.com/{$result['from_user']}' target='_blank'>{$result['from_user']}</a>";
echo "({$result['from_user_name']})";
echo '</div>';
echo '<div class="content">' . "{$result['text']}";
echo '</div></div></div></p>';
//$newClass->request('GET',"http://api.twitter.com/1/statuses/retweet/{$result['id_str']}.json");
$newClass->request('GET',$newClass->url("1/statuses/retweet/{$result['id_str']}.json"));
if ($newClass->response['code'] == 200) {
$data = json_decode($newClass->response['response'], true);
$results = array_merge($results, $data['results']);
}
else {
echo 'Error';
break;
}
}
I try google it for some retweet counts example but to no success.