title: Twitter API 1.1 Hashtag Count
body: <p>I am having an issue figuring out how to return a total count for the number of times a hashtag was used on Twitter.  In the past I used the following code which did work but the "<a href="http://search.twitter.com/search.json" rel="noreferrer">http://search.twitter.com/search.json</a>" address has since been retired by Twitter.  The old code was: </p>
  
  <pre><code>&lt;?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).'&amp;';
        $url .= 'page='.$page;    
        $ch = curl_init($url);
        curl_setopt ($ch, CURLOPT_RETURNTRANSFER, TRUE);
        $json = curl_exec ($ch);
        curl_close ($ch);
        //echo "&lt;pre&gt;";    
        //$json_decode = json_decode($json);
        //print_r($json_decode-&gt;results);
  
        $json_decode = json_decode($json);        
        $total += count($json_decode-&gt;results);    
        if($json_decode-&gt;next_page){
           $temp = explode("&amp;",$json_decode-&gt;next_page);        
           $p = explode("=",$temp[0]);                
           getTweets($hashtag,$p[1]);
        }        
     }
  
     getTweets($hashtag,1);
  
     echo $total; 
  ?&gt;
  </code></pre>
  
  <p>I know that you know have to use a authorized twitter application and have access to be able to pull data.  I was able to set up the app and I can pull a list of data using the following code but I'm not sure how to use that data to come up with a total count.  Can someone help me to get a total by either changing the code I have or helping me with how I should go about it.  Here's the code I have that pulls the hashtag data:</p>
  
  <pre><code>&lt;?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-&gt;get("https://api.twitter.com/1.1/search/tweets.json?q=".$hashtag);
  
  echo json_encode($tweets);
  ?&gt;
  </code></pre>