Updated the meta-detector library (v0.2)

I updated the meta-decector library..

To check out how it works, here's the updated code. (now with nifty comments).

  1. <?php
  2.  
  3. // Inlude the parser
  4. require_once 'Sabre/Web/MetaParser.php';
  5.  
  6. // Change this url
  7. $url = "http://www.rooftopsolutions.nl"
  8.  
  9. // Create an instance
  10. $parser = new Sabre_Web_MetaParser($url);
  11.  
  12. // Explicitly ask to locate and parse the RSD
  13. $parser->setFindRSD(true);
  14.  
  15. // Start making the calls and return the outcome
  16. $sitemeta = $parser->exec();
  17.  
  18. //Open a try..catch block
  19. try {
  20.  
  21. // Dump the results on screen
  22. // This is simular to the demo on http://www.rooftopsolutions.nl/blogdetect
  23.  
  24. echo '<pre>';
  25. print_r($sitemeta);
  26.  
  27. } catch {Exception $e) {
  28.  
  29. echo('Something bad happened: ' . $e->getMessage());
  30.  
  31. }
  32.  
  33. /*
  34. As you can see there's a code for the different feed and api types..
  35. you can try comparing those with the different constants:
  36.  
  37.   Sabre_Web_Blogging::ATOM
  38.   Sabre_Web_Blogging::MOVABLETYPE
  39.   Sabre_Web_Blogging::BLOGGER
  40.   Sabre_Web_Blogging::METAWL
  41.  
  42. and
  43.  
  44.   Sabre_Web_Feed::RSS19
  45.   Sabre_Web_Feed::RSS20
  46.   Sabre_Web_Feed::ATOM
  47.   Sabre_Web_Feed::RDF
  48.  
  49. */
  50.  
  51. ?>

The changelog (warning: dry)

  • Sabre_HTTP_Request now throws more usefull exceptions.
  • Sabre_Web_MetaParser now returns integers for the RSS feed types and API types.
  • Moved RSD code from Sabre_Web_MetaParser to to Sabre_Web_RSDParser.
  • Fixed bugs related to some relative url's

Sourcecode for Meta detector

As promised, I will publish the code for the Meta detector.

You can use these classes to detect meta-information from a website, such as the title, rss feeds and blog api endpoints. I will probably add more features along the way, such as descriptions, keywords, dublin-core metadata and FOAF..

Here are some links:

The library requires the CURL extension to be installed.. I will later on change the HTTP_Request class to allow fopen style and change it into a factory. The code is released under a BSD licence.

  1. <?php
  2.  
  3. // Here's how to use it
  4.  
  5. // Create the instance
  6. $md = new Sabre_Web_MetaParser('http://www.example.org');
  7. // Execute and dump the results
  8. print_r($md->exec());
  9.  
  10. ?>
 1

About

My name is Evert, and I've been writing semi-regularly on this blog since 2006.

I'm currently available for contract work.

more info.

Subscribe

Dropbox

Dropbox is a simple cross-platform online backup and sync application. The first 2GB of space is free, and both you and me get an extra 250MB extra space if you sign up through this link.