Created
June 25, 2010 03:39
-
-
Save brianmichel/452363 to your computer and use it in GitHub Desktop.
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 | |
//This will try to get all of the 4sq events for a given user | |
$url = "http://api.foursquare.com/v1/history?l=250"; | |
$username = "your@4sqemail.here"; | |
$password = "hahapasswordgoeshere"; | |
//Add header for Basic AUTH SICK PLAINTEXT | |
$context = stream_context_create(array( | |
'http' => array( | |
'header' => "Authorization: Basic " . base64_encode("$username:$password") | |
) | |
)); | |
$fetched = file_get_contents($url, false, $context); | |
$xml = simplexml_load_string($fetched); | |
$id = $xml->xpath("//venue/id"); | |
$names = $xml->xpath("//venue/name"); | |
$city = $xml->xpath("//venue/city"); | |
$state = $xml->xpath("//venue/state"); | |
$icon = $xml->xpath("//venue/primarycategory/iconurl"); | |
for($x=count($names)-1; $x >= 0; $x--) | |
{ ?> | |
<p><a target="_blank" href="http://www.foursquare.com/venue/<? echo $id[$x]; ?>"><? echo $names[$x]; ?></a><img src="<? echo $icon[$x]; ?>"/></p> | |
<? } | |
?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment