मुझे यह पता लगाने में कोई समस्या है कि ट्विटर पर हैशटैग का इस्तेमाल कितनी बार किया गया था। अतीत में मैंने निम्नलिखित कोड का उपयोग किया जो काम करता था लेकिन ट्विटर द्वारा "http://search.twitter.com/search.json" पता से सेवानिवृत्त हो गया है। पुराना कोड था:ट्विटर एपीआई 1.1 हैशटैग गणना
<?php
global $total, $hashtag;
//$hashtag = '#supportvisitbogor2011';
$hashtag = '#MyHashtag';
$total = 0;
function getTweets($hash_tag, $page) {
global $total, $hashtag;
$url = 'http://search.twitter.com/search.json?q='.urlencode($hash_tag).'&';
$url .= 'page='.$page;
$ch = curl_init($url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, TRUE);
$json = curl_exec ($ch);
curl_close ($ch);
//echo "<pre>";
//$json_decode = json_decode($json);
//print_r($json_decode->results);
$json_decode = json_decode($json);
$total += count($json_decode->results);
if($json_decode->next_page){
$temp = explode("&",$json_decode->next_page);
$p = explode("=",$temp[0]);
getTweets($hashtag,$p[1]);
}
}
getTweets($hashtag,1);
echo $total;
?>
मुझे पता है कि आपको पता है कि एक अधिकृत ट्विटर एप्लिकेशन का उपयोग करना है और डेटा खींचने में सक्षम होना है। मैं ऐप सेट अप करने में सक्षम था और मैं निम्नलिखित कोड का उपयोग कर डेटा की एक सूची खींच सकता हूं लेकिन मुझे यकीन नहीं है कि कुल डेटा के साथ आने के लिए उस डेटा का उपयोग कैसे करें। क्या कोई मेरे पास या तो कोड बदलकर या मुझे इसके बारे में मदद करने के लिए मेरी सहायता करने में कुल मिलाकर मेरी सहायता कर सकता है। यहाँ कोड मेरे पास है हैशटैग डेटा खींचती है:
<?php
session_start();
require_once("twitteroauth.php"); //Path to twitteroauth library
$hashtag = "MyHashtag";
$consumerkey = "MYINFOWOULDBEHERE";
$consumersecret = "MYINFOWOULDBEHERE";
$accesstoken = "MYINFOWOULDBEHERE";
$accesstokensecret = "MYINFOWOULDBEHERE";
function getConnectionWithAccessToken($cons_key, $cons_secret, $oauth_token, $oauth_token_secret) {
$connection = new TwitterOAuth($cons_key, $cons_secret, $oauth_token, $oauth_token_secret);
return $connection;
}
$connection = getConnectionWithAccessToken($consumerkey, $consumersecret, $accesstoken, $accesstokensecret);
$tweets = $connection->get("https://api.twitter.com/1.1/search/tweets.json?q=".$hashtag);
echo json_encode($tweets);
?>