Stuart_Westgate Posted January 31, 2013 Share Posted January 31, 2013 At present I have wrote the code below to parse Twitter hashtags "#emotionalclothing". What I really want to do is parse hashtags or status updates with any instance of the phase "emotionalclothing". So say there's a word that reads "blahemotionalclothingblah" in a status update how could retrieve that status update just by searching for a regex with "emotionalclothing" in it? Here's my code so far: Thanks Stuart <?php $pagetitle = "Pull Twitter Hashtags"; function getTweets($hash_tag) { $url = 'http://search.twitter.com/search.atom?q='.urlencode($hash_tag) ; echo "<p>Connecting to <strong>$url</strong> ...</p>"; $ch = curl_init($url); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, TRUE); $xml = curl_exec ($ch); curl_close ($ch); //If you want to see the response from Twitter, uncomment this next part out: //echo "<p>Response:</p>"; //echo "<pre>".htmlspecialchars($xml)."</pre>"; $affected = 0; $twelement = new SimpleXMLElement($xml); foreach ($twelement->entry as $entry) { $text = trim($entry->title); $author = trim($entry->author->name); $time = strtotime($entry->published); $id = $entry->id; echo "<p>Tweet from ".$author.": <strong>".$text."</strong> <em>Posted ".date('n/j/y g:i a',$time)."</em></p>"; } return true ; } getTweets('#emotionalclothing'); ?> Link to comment https://forums.phpfreaks.com/topic/273878-how-can-i-parse-twitter-hashtags-with-a-certain-word-in/ Share on other sites More sharing options...
Jessica Posted January 31, 2013 Share Posted January 31, 2013 Uhm. Remove the # from your search. Link to comment https://forums.phpfreaks.com/topic/273878-how-can-i-parse-twitter-hashtags-with-a-certain-word-in/#findComment-1409379 Share on other sites More sharing options...
Stuart_Westgate Posted January 31, 2013 Author Share Posted January 31, 2013 I really wish it was that simple lol. I've tryied that but can only get feeds back with just that phase e.g; "emotionalclothing. However, if it a phase like this "jfjemotionalclothingjgfdhs"; it won't grab that for me! :-( Link to comment https://forums.phpfreaks.com/topic/273878-how-can-i-parse-twitter-hashtags-with-a-certain-word-in/#findComment-1409382 Share on other sites More sharing options...
Jessica Posted January 31, 2013 Share Posted January 31, 2013 Sounds like that's a limitation of twitter's API. Link to comment https://forums.phpfreaks.com/topic/273878-how-can-i-parse-twitter-hashtags-with-a-certain-word-in/#findComment-1409383 Share on other sites More sharing options...
Stuart_Westgate Posted January 31, 2013 Author Share Posted January 31, 2013 I'm thinking the same thing Jess but their must be a way to look for certain words within a status other then this. Link to comment https://forums.phpfreaks.com/topic/273878-how-can-i-parse-twitter-hashtags-with-a-certain-word-in/#findComment-1409385 Share on other sites More sharing options...
Stuart_Westgate Posted February 4, 2013 Author Share Posted February 4, 2013 For anyone viewing this, there is a Twitter limitation to this. :-( Link to comment https://forums.phpfreaks.com/topic/273878-how-can-i-parse-twitter-hashtags-with-a-certain-word-in/#findComment-1410074 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.