//
// Copyright 2011 Scott Buffington (scotbuff@gmail.com)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// See for a copy of the GNU General
// Public License.
//
////////////////////////////////
//
// Version 0.1
//
define('RUNKEEPER_UID', 'Your Runkeeper UID');
define('YOUR_NAME', 'Your Name');
define('YOUR_EMAIL', 'youremail@address.com');
date_default_timezone_set('UTC');
Header("Content-type: text/xml");
print "\n";
print "\n";
print "\n";
print "\n";
print "".YOUR_NAME."'s Runkeeper Activities\n";
print "http://runkeeper.com/user/".RUNKEEPER_UID."/profile\n";
print "Runkeeper Activities\n";
print "http://backend.userland.com/rss\n";
print "".YOUR_EMAIL."\n";
print "".YOUR_EMAIL."\n";
print "en\n";
print "Copyright birth-2012 a Scott Buffington Production\n";
print "Buffalized Runkeeper\n";
print "\n";
print "".YOUR_NAME."'s Runkeeper Activities\n";
print "\n";
print "http://buffington.me/runkeeper/running.jpg\n";
print "\n";
print "\n";
$url = "http://runkeeper.com/user/".RUNKEEPER_UID."/activity/";
$raw = file_get_contents($url);
$counter = 0;
$newlines = array("\t","\n","\r","\x20\x20","\0","\x0B");
$content = str_replace($newlines, "", html_entity_decode($raw));
preg_match_all("|/activity/(.*)\">|U",$content, $rows);
foreach ($rows[0] as $row){
$counter += 1;
if ($counter < 12) {
if ($counter == 1) {
continue;
} else {
$row = str_replace("/activity/", "", $row);
$activity_id = str_replace("\">", "", $row);
$url ="http://runkeeper.com/user/".RUNKEEPER_UID."/activity/".$activity_id;
$raw = file_get_contents($url);
$content = str_replace($newlines, "", html_entity_decode($raw));
preg_match_all("|activityDateText(.*)::|U",$content, $actdates);
foreach ($actdates[0] as $actdate) {
$actdate = str_replace("activityDateText\">","", $actdate);
$actdate = str_replace("::","", $actdate);
$actdate = str_replace("\xa0","", $actdate);
$newdate = strtotime(trim($actdate));
$newdate = date("Y-m-d\\TH:i:s\\Z",$newdate);
}
$jsonurl = "http://runkeeper.com//ajax/pointData?activityId=".$activity_id;
$json = file_get_contents($jsonurl,0,null,null);
$json_output = json_decode($json);
print "\t\n";
print "\t\t{$json_output->feedData->name}\n";
print "\t\t{$url}/\n";
print "\t\tfeedData->caption}\n";
print "\t\t\t\t{$json_output->feedData->description}\n";
print "\t\t]]>\n";
print "\t\t".RUNKEEPER_UID."\n";
print "\t\t$newdate\n";
print "\t\n";
}
}
}
print "\n";
print "\n";
?>