From 63a481a189fa803fb40dd21cf1ba59d7764fbb1a Mon Sep 17 00:00:00 2001 From: Aaron Parecki <aaron@parecki.com> Date: Mon, 8 Aug 2016 12:16:01 -0700 Subject: [PATCH] Create foursquare.html --- foursquare.html | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 foursquare.html diff --git a/foursquare.html b/foursquare.html new file mode 100644 index 0000000..8e17ade --- /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> -- GitLab