Skip to content

Instantly share code, notes, and snippets.

@reid
Created September 26, 2008 01:24
Show Gist options
  • Save reid/13002 to your computer and use it in GitHub Desktop.
Save reid/13002 to your computer and use it in GitHub Desktop.
Parse a Yahoo! Pipe of Twitter feeds to make wordle.net friendly output
<?php
/* twipple.php
* Yahoo! Pipes + Twitter + Wordle
*
* Usage: php twipple.php | pbcopy
* ...then paste into wordle.net
*/
$pipe_url = 'http://pipes.yahoo.com/pipes/pipe.run?_id=0Dd3hqOG3RGDdbrnbLsjiw&_render=php';
// Run a Yahoo! Pipe to get some Twitter feeds
$serialized = file_get_contents($pipe_url);
$arr = unserialize($serialized);
$items = $arr['value']['items'];
foreach ($items as $item) {
$c = $item['content'];
// Get rid of the Twitter username and trim whitespace
$c = explode(':', $c);
array_shift($c);
$c = implode(':', $c);
$c = trim($c);
// Remove Twiter @usernames, transform #tag into tag
$t = explode(' ', $c);
foreach ($t as $k => $word) {
if ($word[0] == '@') {
unset($t[$k]);
continue;
}
if ($word[0] == '#') {
$t[$k] = substr($word, 1);
}
}
$c = implode(' ', $t);
echo strtolower($c) . "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment