You can use FourSquare’s public APIs to display a list of nearby places in your Windows Phone app. Here’s a quick tip on how to do it.
Step 1: Register your app on FourSquare
You will need to register your app and get a client ID and client secret before you can use any of its APIs. Register here.
https://foursquare.com/developers/apps
Step 2: Define a class Venue to hold the JSON response
The Venue
object returned has lots of information about any particular place. You can play around with and put it to many different uses. Here’s the whole RootObject
returned by the venue API.
Step 3: Get the device’s Geo Coordinates
Next, use the Geolocator
class in Windows Phone 8.1 to get device’s current location.
Step 4: Define a ListView to display nearby places
Define a simple ListView
and add a TextBlock
in its DataTemplate
, binding it to name
. To add to the fun, we have added a FourSquare logo in the list’s footer.
Step 5: Make a call to FourSquare’s Venues API
The getNearbyPlaces method makes a call to the venues API of Foursquare to return a JSON response containing a list of nearby places. Finally bind the result to the ListView
.
Recent Comments