Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kevinold/3018592 to your computer and use it in GitHub Desktop.
Save kevinold/3018592 to your computer and use it in GitHub Desktop.
Simple Twitter Timeline with AngularJS
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<title>Twitter widget</title>
<link href='http://fonts.googleapis.com/css?family=Lato:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="../../css/main.css">
<script src="../../js/angular-1.0.0rc10.min.js"></script>
<script type="text/javascript">
function twitter_controller($scope, $http) {
var twitter_api_url = "http://api.twitter.com/1/statuses/user_timeline.json"
, username = "bechhun"
, config = {
params : {
screen_name: username
, callback : "JSON_CALLBACK"
, include_rts : true
, count: 5
, clientsource : "TWITTERINC_WIDGET"
, "1340767850386": "cachebus"
}
};
$http.jsonp( twitter_api_url, config ).success(
function(data, status, headers, config){
$scope.tweets = data;
}
);
}
twitter_controller.$inject = ['$scope', '$http'];
</script>
</head>
<body class="demo">
<section ng-app>
<div id="twitter-feed" ng-controller="twitter_controller">
<ol>
<li ng-repeat="tweet in tweets">
{{ tweet.text }}
</li>
</ol>
</div>
</section>
</body>
</html>
@christopherhill
Copy link

FYI, this uses the v1 API which has been retired.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment