Exemple #1
0
    ?>

<?php 
    //see if there are any records in the db
    //order by timestamp desc
    //if there are, get the most recent record's timestamp and set it as sinceid as option in history query
    $destinationsQuery = mysql_query("select foursquarecheckinid from destinations where userid=" . $_SESSION['currentUserID'] . " order by foursquarecheckinid desc");
    if (mysql_num_rows($destinationsQuery) == 0) {
        $sinceID = "";
    } else {
        $resultRow = mysql_fetch_object($destinationsQuery);
        $sinceID = $resultRow->foursquarecheckinid;
    }
    //get recent checkins
    //$venues = $foursquareObj->get_history();
    $venues = $foursquareObj->get_history(array("sinceid" => $sinceID))->checkins;
    //a cleaner approach: filter out 'shout-only' checkins from $venues so they don't show up in the total number of venues
    $numVenues = sizeof($venues);
    //echo("Number of new stops: ".$numVenues."<br />");
    //if using a sinceid, ordering will be oldest to newest. if not, ordering will be newest to oldest
    if ($sinceID != "") {
        $venues = array_reverse($venues);
    }
    //insert data from foursquare into database
    for ($i = 0; $i < $numVenues; $i++) {
        //need to check each venue to make sure it is a legal venue
        $currentVenue = $venues[$i];
        if (isset($currentVenue->venue->id)) {
            $currentVID = $currentVenue->venue->id;
            $currentVenueCheckinTime = $currentVenue->created;
            $currentVenueLongURL = "http://foursquare.com/venue/" . $currentVID;