Welcome Guest Search | Active Topics
RSS feed php script Options · View
dra
Posted: 19 Feb 10


Posts: 21
Location: United States
I've put together a simple RSS feed reader php script that should work with Run Saturday. The script is based on the xml parser described and documented at SitePoint.

The script is fairly simple to implement. You will need to make two changes:

1) Find the point toward the bottom of the program and change the text <username> to your Run Saturday user name.

2) Find the point toward the bottom of the program and change the text <google_api_key> to your Google Maps API key. You must get a Google Maps API key from here. The script will not work without it. Be sure to leave the starting and ending quotes around your user name and the API key.

Save the script in a file ending in .php (example: myscript.php) and put the script someplace where an http server with php enabled can serve it. Then point your browser at the script and you should see your Run Saturday activities, including a static Google map, presented in a nice tabular form. You can see an example at my outdoors page - click the "Training Activities" link under the Reports menu on the left-hand side of the page.

You can change the formatting of the output by editing the endElement function as you like. You can change the set of tags that are parsed by editing the characterData function.

If your page gets more than a few loads per unit time, it is probably a good idea to consider caching. There is a good discussion of how to do that here.

I probably won't have much time to offer support on this script, but it should get you on your way toward using the Run Saturday AnalysisRSS feed to add activities to your own page. Enjoy!

Dave

The script is available here.

magnacarter
Posted: 19 Feb 10


Posts: 277
Location: United Kingdom
Thats superb Dave,

I suspect that loads of RS people will be able to benefit from your efforts!

I'm certainly going to take a look at how I might use it on my own site

Be nice to see a series of mods being made to the script and posted here... a kind of open source RunSaturday sharing thread!!!!... I'm unfortunately competely incompetent with php, so it won't be me taking the lead...... Blushing

If you like the site: become a facebook fan, rate us on SportTracks, and talk about us everywhere!



KarmaComa
Posted: 19 Feb 10


Posts: 298
Location: Canada
Nice, this place is evolving into an open app

"Triathlon is just the equation that allows us to reap the passion of life in proportion to the work we put in" - Mitch Thrower
dra
Posted: 24 Apr 10


Posts: 21
Location: United States
It was cold and rainy last night, so rather than go for a ride, I made a few improvements to my RSS parser script that should make it more user-friendly.

First, I internationalized the script a bit. The script should now display all results in your preferred local units (assuming you have these set up on RS).

Second, I added the capability to input the target username via the calling URL. Thus, it is possible to use the script with multiple usernames without having to edit the script each time. Also, you won't need your own Google Maps API key if you call the script remotely from my machine.

You can download a copy of the revised script here. Also, you can link directly to the script using this url: http://dave.tycho.ws/st/actlist.php?targetuser=dra - just change the targetuser to your favorite username.

Third, I spent some time thinking about the best way to embed the activities list in a blog. The best way would be to use SSI, but that doesn't really work well due to W3C security policies if you don't want to host the script locally.

The second best (and most workable) way to do this is to embed the script url using an iframe. But even an iframe has some cross-browser compatibility and scrollbar issues. However, the careful use of some CSS and conditional comments can make it work reasonably well for most browsers.

I've put together a short html file that will call the php script and render the results in your browser. This file doesn't require php on your web server. To install it, copy the html below and save it in a text file named something like activitylist.htm in the filespace of your web server, and then point your browser to it. (in fact, if you just want to run it locally, it doesn't even require a web server. Just save the html as a text file and load it into your browser using the "Open File" command). Be sure to change the name of the targetuser in the file before saving - you need to do it on two different lines in the file, once for MS Internet Explorer and once for Mozilla-based browsers.

Here's the html code to call the script:
Code:

<html>
<head>
<title>RunSaturday Activities List</title>
<style type="text/css">
#iframe_good {
position:absolute;
top: 30px;
left: 0px;
right: 0px;
bottom: 0px;
</style>
</head>
<!--[if IE]><body scroll="no"><![endif]--><!--[if !IE]><!--><body><!--<![endif]-->
<div>
See my last 10 activites from <a href="http://www.runsaturday.com" target="_blank">RunSaturday.com</a>!<br />
</div>
<!--[if !IE]><!-->
<div id="iframe_good">
<iframe scrolling="auto" id="iframe" frameborder="0" src="http://dave.tycho.ws/st/actlist.php?targetuser=dra" width="100%" height="100%">
</iframe>
</div>
<!--<![endif]-->
<!--[if IE]><iframe id="iframe_bad" src="http://dave.tycho.ws/st/actlist.php?targetuser=dra" width="100%" height="100%" frameborder="0"><![endif]-->
</body>
</html>


If you want to embed an iframe containing my php script into your blog, don't just wrap the above html in another iframe. If you do, you will end up with the same old double scrollbar problem. Instead, use the html above as a guide to making an iframe with a single scrollbar.

Enjoy!
Dave
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

Clean Slate theme by Jaben Cargman (Tiny Gecko)
Yet Another Forum.net

Recent Photos

Recent PBs

Aonikenk 0:55:19
14km Road - 14km de Belvédère
drumball 4:08:13
45k - Great Ocean Road Real Estate Marathon
1bubobubo 0:27:32
6.2k - Žehrovický Kalspotkros
Monika 2:56:58
36k/18k - ŠUTR 54
index 0:24:53
6.1k - 1. LBP 2013 - Pisárky
Luky 3:29:11
Marathon - Volkswagen Maraton Praha
1bubobubo 3:23:26
Marathon - Prague Marathon 2013
runaway_chris 1:38:58
0.4k/22k/5k - 11. MRRC Stadt-Triathlon München

Recent Videos