[Code] Display checkin list from Foursquare


Foursquare now limits even more the requests sent to their servers, therefore you must use another method.

If you’ve ever wondered how to display a simple list of your latest Foursquare checkins, with a Googlemap link too and without having to install yet another plugin (if you use a CMS, such WordPress for example), here’s the code you need.
This snippet can be used in any site really, all you have to do is edit a few things and you’re ready to go.

// Display the latest Foursquare checkins - Shambix

	function fsq_shambix() {
		$foursq_feed_URL ='VE5OO4HCULPTZQGYC45DLMMV4CSHHFJS'; //this is your user code, to get it just go to https://foursquare.com/feeds
		$foursq_counts = 9; //how many checkins you want to display
		$foursq_final_feed_URL = 'https://feeds.foursquare.com/history/'.$foursq_feed_URL.'.rss';
		$foursq_object = simplexml_load_file($foursq_final_feed_URL . '?count=' . $foursq_counts);
		$items = $foursq_object->channel;
		$foursq_checkin = $items->item;
		$small_image_width = '85'; //map width
		$small_image_height = '85'; //map height
		//$icon = '|icon:https://foursquare.com/img/categories/shops/default.png'; //if you want to use a custom marker, change the image url and uncomment this line and comment out the next one
		$icon = ''; //if you don't want to use a custom marker leave the code as it is, otherwise read the line above
               // DO NOT edit below this line
		$count = 0;
		foreach ($foursq_checkin as $item) {
		$geopoint = $item->children('georss', true)->point;
		$descritpion = $item->description;
		$title = $item->title;
		$img_src = "https://maps.google.com/maps/api/staticmap?sensor=false&size={$small_image_width}x{$small_image_height}&zoom=15&markers=size:small$icon|$geopoint";
		$img = "$title";
			if ($item->link != '') {
					echo "
  • "; $count++; if ($count == $foursq_counts) {break;} } } }

    To activate the function, use the below code wherever you want the list to show up.

    <div class="fsq">
        <h4>My Foursquare</h4>
        <ul><?php fsq_shambix(); ?></ul>
    </div>

    Now have fun adding some style to the list in your .css!

    Jany Martelli

    I’m a Digital Consultant, Front-End Developer, specialized in WordPress.
    I help companies, professionals and startups grow with technology and a winning digital strategy, I hand-pick and coordinate the perfect team for them, plan projects from the ground-up, develop & deploy websites, online stores and apps.