bakineggs (owner)

Revisions

gist: 147316 Download_button fork
public
Public Clone URL: git://gist.github.com/147316.git
Embed All Files: show embed
tweets.php #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<ul>
<?php
function h($string) {
  return htmlentities(replace_quotes($string), ENT_QUOTES);
}
function replace_quotes($string) {
  $CHANGES = array(
    "\xe2\x80\x93" => '-',
    "\xe2\x80\x94" => '-',
    "\xe2\x80\x9d" => '"',
    "\xe2\x80\x9c" => '"',
    "\xe2\x80\x98" => "'",
    "\xe2\x80\x99" => "'"
  );
  return str_replace(array_keys($CHANGES), array_values($CHANGES), $string);
}
$response = file_get_contents('http://twitter.com/statuses/user_timeline.json?id=licensepal');
$tweets = json_decode($response, true);
foreach ($tweets as $tweet) {
  echo '<li class="tweet" id="tweet_' . $tweet['id'] . '">';
  echo '<span class="text">' . h($tweet['text']) . '</span>';
  echo '<span class="created_at">' . h($tweet['created_at']) . '</span>';
  echo '</li>';
}
?>
</ul>