Created
May 1, 2012 17:24
-
-
Save mreidsma/2569821 to your computer and use it in GitHub Desktop.
Simple foursquare badge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Show a small badge with your most recent foursquare login | |
// Pass your Foursquare history RSS feed to the script to show your latest login | |
// To get your feed, sign in & go to http://foursquare.com/feeds | |
// This will make your feed public to anyone who looks at the source of your site! | |
// | |
// We use this in Sharepoint inside a <gasp> iframe, like this: | |
// | |
// <iframe src="http://mywebsite.com/foursquare.php?feed=https://feeds.foursquare.com/history/sjahdasjdhajdasd.rss"></iframe> | |
// | |
// I'm sure there is a more elegant way, but this only took 20 minutes. | |
date_default_timezone_set('America/New_York'); // Obviously, make this match yours. | |
// Script takes the RSS feed from foursquare. | |
$feedUrl = $_GET['feed']; | |
$rawFeed = file_get_contents($feedUrl); | |
$xml = new SimpleXmlElement($rawFeed); | |
$location = (string)$xml->channel->item[0]->title; | |
$time = strtotime($xml->channel->item[0]->pubDate); | |
$person = (string)$xml->channel->title[0]; | |
$magic = explode(" for ", $person); | |
$name = $magic[1]; | |
$checkintime = date("g:ia, M j, Y", $time); | |
// If you use this script for multiple people, set conditionals for images | |
// If it's just you, just set the $img variable to your photo's URL | |
// If I have time someday I'll grab the user's foursquare pic with cURL or something. | |
if($name == "Matthew R.") { | |
$img = "http://myawesomeimage.com"; | |
} | |
if($name == "Jimmy T.") { | |
$img = "http://myevenbetterimaage.com"; | |
} | |
?> | |
<style> | |
div.checkin { font-family: helvetica, arial, verdana, sans-serif; font-size: 1em; } | |
div.checkin div { width: 5em; float: left; } | |
div.checkin div img { max-width: 100%; margin-bottom: .5em;} | |
div.checkin p { margin-left: 70px; padding-top: .7em; } | |
</style> | |
<div class="checkin"> | |
<div><img src="<?php echo $img; ?>" alt="<?php echo $name; ?>" /></div> | |
<p><?php echo $name; ?> @ <br /><strong><?php echo $location; ?></strong><br /> | |
<?php echo $checkintime; ?></p> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment