diff --git a/foursquare.html b/foursquare.html new file mode 100644 index 0000000000000000000000000000000000000000..8e17ade403d63a9e8c01c3057a534b568073b9d7 --- /dev/null +++ b/foursquare.html @@ -0,0 +1,45 @@ +<html> +<head> + <title>Example App</title> + <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> +</head> +<body> + + <div id="login"> + <a href="https://foursquare.com/oauth2/authenticate?client_id=IFMKONPESAZI2NG3D2QWFTJISPVEITNB2IEKTZ0WVLGZKEFI&response_type=token&redirect_uri=http://oauth2.dev/code/foursquare.html">Log In</a> + </div> + + <div id="signed-in" style="display: none;"> + <h2 id="header">Your last 10 checkins</h2> + <div id="checkins"> + </div> + </div> + + <script> + $(function(){ + var token; + if(window.location.hash + && (token=window.location.hash.match("access_token=([^&]+)")[1])) { + + $("#login").hide(); + + var checkins_url = "https://api.foursquare.com/v2/users/self/checkins" + + "?v=20150201&limit=10&oauth_token="+token; + + $.getJSON(checkins_url, function(data){ + var checkins = data.response.checkins.items; + var html = ''; + $(checkins).each(function(i,c){ + html += '<a href="https://foursquare.com/_/checkin/' + c.id + '">' + + c.venue.name + '</a><br>'; + }); + $("#checkins").html(html); + $("#signed-in").show(); + }); + + } + }); + </script> + +</body> +</html>