How To Deal With High Gear Media API Using PHP And XPath
For the serious players in the automotive industry on the net there is a new way to improve their sites. We had this feed for a while, but now with the new improvements and after big players (e.g. yahoo autos) have been happy with it, we wanted to share it with others around the world.
For developers that are not used to work with XML, XPath and other goodies, here is a short sample of code that will show you how easy it is to fetch our full feed. Unlike the previous post about our regular RSS feed, I’ve used here some basic functionality that anyone that used php (5.2+) will have under their belt.
<?php
/**
* @author Ido Green
*
* @since 04/10/2010
*
* @abstract Simple example how to fetch High Gear Media Full API using xPath
*
* @see greenido.wordpress.com
*
* @copyright HighGearMedia INC. 2010
*
*/error_reporting(E_ALL); // Always good to have it in development mode
$feed = new DOMDocument();
$feed->load('http://www.thecarconnection.com/api?uid=YourApiUserKey&cat=bottom-line');
if (isset($feed->documentElement)) {
$xpath = new DOMXPath($feed);
// Lets register TheCarConnection namespace
$xpath->registerNamespace('tcc', 'http://www.thecarconnection.com/rss');
// Now we looping on all the items and for each one we are extracting some data
foreach ($xpath->evaluate('//item') as $entryNode) {
// Simple way to get the title,desc per item
echo "Title: " . $xpath->evaluate('string(title)', $entryNode), "\n";
echo "Description " . $xpath->evaluate('string(description)', $entryNode), "\n";
// and some more interesting capabilities of xPath - we fetching the spec that is under tcc namespace for car details
echo "Make: " . $xpath->evaluate('string(tcc:review[1]/tcc:cardetails[1]/tcc:make[1])', $entryNode), "\n";
echo "Model: " . $xpath->evaluate('string(tcc:review[1]/tcc:cardetails[1]/tcc:make[1])', $entryNode), "\n";
echo "Rating: " . $xpath->evaluate('string(tcc:review[1]/tcc:cardetails[1]/tcc:rating[1])', $entryNode), " Out of 10\n";
echo "============\n";
}
} else {
echo 'Error: Could not fetch the feed';
}
You can also clone this code from github using: git clone git://gist.github.com/865542.git gist-865542
So it’s easy, right? You can load these feed for each site from our network.
For example: http://www.motorauthority.com/api?uid=YourUserKey&cat=reviews
Will give you all the reviews from Motor Authority.
For more specific custom calls you may use these parameters:
- uid – your user ID
- cat – you can choose: reviews / bottom-line / tips / blogs
If you wish to get just the summaries of the bottom-line use: bottomline-summary - media – Use 0 for strip html and media=1 to have our HTML format in the call.
- from/to – Use unix time stamp (e.g. 1206514800 and yes… the ‘from’ need to be lower then the ‘to‘)
- limit – Up to 100 items. The default is 10.
- limited-links – When it’s equal 1 we will give you just 5 links per item.
- version – You will only need it if you wish to get reviews for cars that are older then 2008. Then use: version=0
- morelinks – Use 1 if you wish to get links from thecarconnection.com or 0 if you don’t want links.
(*) Note that the bold parameters are mandatory.

If you wish to have quality automotive content on your site please feel free to approach High Gear Media
(feedback at HighGearMedia.com) and get a user ID. With more then 1000 new items of content per month, there are something for every car lover girl.
How To Work With High Gear Media RSS Feed In (less then) 4 Minutes
For all the girls that asked me time after time ‘How/Who/When/Why?’ and for all the ones that want to have on their blog the best automotive content around the web… This short code example will harness you with a knowledge to fetch High Gear Media customizable feed and have it on your site. The first thing you need to do in order to save yourself some leg work is to install Zend Framework.
Why reinvent the wheel, right?
The good people that work with Zend build for us some nice components that save us lots of work. For example, to parse an Atom (or RSS) feed – you should use their class and in few lines of code, you can be productive and happy.
After the installation, you can copy & paste the code below and you good to go.
<?php
/**
* @author Ido Green
*
* @since 04/01/2010
*
* @abstract Simple example how to fetch High Gear Media API (XML feed).
* You should have Zend Framework (1.9.4 and above).
*
* @see greenido.wordpress.com
*
* @copyright HighGearMedia INC. 2010
*
*/
// Set error reporting to ALL - Always good when you developing new features
error_reporting(E_ALL);
// Lets make sure we can find Zend Framework lib. (You might want to change it base on your local
// environment.
set_include_path(get_include_path() . PATH_SEPARATOR . "../");
// get the feed library
require_once 'Zend/Feed.php';
try {
$rss = Zend_Feed::import('http://feeds.highgearmedia.com/?sites=thecarconnection,greencarreports,allaboutprius');
} catch (Exception $e) {
echo $e->getMessage(); // In case something didn't work - lets see it.
exit (-1);
}
$feedItems = array();
// Loop through the items in the feed
foreach ($rss as $item) {
$itemElements = array(
'title' => $item->title(),
'description' => $item-<description(),
'link' => $item->link(),
'pubDate' => $item->pubDate(),
'author' => $item->author()
);
array_push($feedItems, $itemElements);
}
echo "\nThe HGM feed we got:\n";
// dump all items
var_dump($feedItems);
// In case some other process want to check if we finished correctly.
exit(0);
?>
The feeds can be fully customize according to your interested topics. For example:
- http://feeds.highgearmedia.com/?sites=thecarconnection&tags=green – This will fetch you all the content from The Car Connection that is tagged with Green
- http://feeds.highgearmedia.com/?sites=thecarconnection,greencarreports,allaboutprius – This example show you how to fetch content from 3 sites:The Car Connection, Green car reports and All About Prius.
- http://feeds.highgearmedia.com/?sites=greencarreports&tags=ford – This will give you all the content from Green Car Reports that is tagged with Ford
Please feel free to share you experience using the comments.
The Top 10 Air Time Around The World
Did I told you I love red-bull?
They are a great company that invest in crazy/cool people.
Long conversation with DHH
It’s (too) long conversation in ‘This week in Startup’ but you might want to browse it.
Lots of good stuff and it’s funny to see how David is refusing to the virtual offers Mr. C. is throwing in his direction.
Enjoy.
Marathon (short) Tutorial
Here is (yet another) lighting talk I gave at the Java Posse Roundup 2010
It’s a short presentation that give you the basic idea what is all about this trend of running 42.195 Km (or 26.2 miles if you want to count less).
Planning – there are lots of good resources out on the web. Here is one that I’ve used – It’s A Guru trainer site. You can pick the right plan base on your current shape. Another good online tool is this pace calculator. But like anything in life, it’s all about execution! You must follow the plan and do your best to stick with the runs.
The hard part and the most important part of any plan is the ‘long runs’. These runs build you body and make sure it will be able to do the distance and be active for 3 to 5 hours.
Be Strong and (try to) have fun.
Java Posse Roundup 2010 – Suggested Books

With so many great recommendations…
I felt it was right to share it with the world. Here are some of the books that people in the Java Posse Roundup 2010 recommended you to read (quickly).
Agile Books
- Lean software development an Agile Toolkit by Mary and Tom Poppendieck.
- Succeeding with Agile by Mike Cohn.
- User Stories Applied: For Agile Software Development by Mike Cohn
- Agile Estimating and Planning by Mike Cohn
- Practices of an Agile Developer by Andy Hunt
- Agile Retrospectives; Making Good Teams Great by Esther Derby and Diana Larsen
- Clean Code: A Handbook of Agile Software Craftsmanship by Robert C. Martin
Testing Books
- xUnit Test Patterns by Gerard Meszaros
- Growing Object-Oriented Software Guided By Tests by Steve Freeman and Nat Pryce
Complex Event Processing
- The Power of Events: An Introduction to Complex Event Processing in Distributed Enterprise Systems by David C. Luckham
Version Control
- Pro Git, by Scott Chacon
- Version Control with Git: Powerful Tools and Techniques for Collaborative Software Development by Jon Loeliger
- Pragmatic Version Control Using Git, by Travis Swicegood
Scala
- Beginning Scala by David Pollack
- Programming in Scala by Martin Odersky, Lex Spoon, and Bill Venners
JavaScript
- JavaScript: The Good Parts by Douglas Crockford
Career Books
- Career 2.0 by Jared Richardson.
- Passionate Programmer by Chad Fowler.
- Getting Things Done: The Art of Stress-Free Productivity by David Allen
- The Myth of Multitasking: How “Doing It All” Gets Nothing Done by Dave Crenshaw
- The Power of a Positive No: Save The Deal Save The Relationship and Still Say No by William Ury
- What Should I Do with My Life?: The True Story of People Who Answered the Ultimate Question by Po Bronson
Business
- Peopleware by Tom DeMarco.
- Small Giants by Bo Birlingham.
- Nudge by Richard H. Thaler.
- Drive, by Daniel H. Pink.
- Snakes in Suits: When Psychopaths Go to Work by Paul Babiak and Robert D. Hare
- Rework by Jason Fried and David Heinemeier Hansson
- The Management Myth: Why the Experts Keep Getting it Wrong by Matthew Stewart
- Freakonomics: A Rogue Economist Explores the Hidden Side of Everything (P.S.) by Steven D. Levitt and Stephen J. Dubner
- Free: The Future of a Radical Price by Chris Anderson (BTW, you can get a free version in iTune for the audio version)
- In Search of Stupidity by Merrill R. (Rick) Chapman
Software Projects and Their Teams, Groups, Processes and People
- Adrenalin Junkies and Template Zombies: Understanding Patterns of Project Behaviour by Tom DeMarco, Peter Hruschka, Tim Lister, Suzanne Robertson
Release It! writing and maintaining software from an operations perspective
On Intelligence by Jeff Hawkins – How a new understanding of the brain will lead to the creation of truly intelligent machines
The Web Is Shifting
Here is another lighting talk I’ve planed to this year Java Posse Roundup. Unfortunately, I didn’t have time to give it. So in order to share it with some girls that might find it interesting – Here you go:
The web is becoming more sociable than searchable, research firm Hitwise said that the two sites accounted for 14 per cent of all US internet visits last week. Facebook’s home page recorded 7.07 per cent of traffic and Google’s 7.03 per cent. You may read more about the fact that Facebook got more unique users in the USA then Google all last week… so it’s clearly the direction that the web is moving. I only wonder, what are people doing all this time on Facebook.

Facebook is like a Starbucks (You know… friends don’t let they friend drink there) where everyone hangs out for hours but almost never buys anything. The revenue gap between sites like Facebook and Google should narrow over time. Cost-per-click search ads are extremely good at harvesting intent, but bad at generating intent.
Startup Best Practices
Here is the presentation I’ve used in my lighting talk at the Java Posse roundup 2010
There are just few ‘lessons’ here. IMHO, the important ones.
Over the past 15 years, I’ve been in start ups and swat teams in side big companies. There are lots of good things that I’ve learn, but also, lots of bold examples to how not to run things. In the end of the day, it’s all about peopleware and open commutation. But like any other aspect in life, lots of other methods you can use in order to be better and excel.
Disclaimer: In some of the slides I took some ideas from Rework book.
Why you should run on regular bases?
Here are few points that I’ve took from the article in the WSJ:
* People who exercise regularly heal from colds 20-30% faster.
* People who walked briskly for 45 minutes, 5 days a week for 12-15 weeks reduced their number of sick days by 25-50%.
* 36% of US adults didn’t engage in ANY leisure activities in 2008. Can this be true?
* Exercise can lower the risk of stroke by 27%, diabetes by 50%, high-blood pressure by 40%, risk of recurring breast cancer by 50%, colon cancer by 60%, Alzheimer’s disease by 40%.
* Physical activity reduces erosion of telomeres, which essentially is an anti-aging effect at the cellular level.
So next time you thinking on doing some sport activity – follow Nike rule “Just do it!”.

