CodeIgniter Rightmove V3 .blm Data Feed Parser Library

October 2nd, 2010 - Posted by Steve Marks to PHP, Web Development.

Need A Rightmove Feed Writing?

I’ve nearly 10 years experience working alongside property portals and writing data feeds to both send and receive BLM feeds. If you need a data feed writing, please get in touch and I’ll be happy to discuss your requirements with you and get something in place.

About The .blm Data Feed Format

Initially introduced by Rightmove, the .blm (Bulk Load Mass) data feed format for transferring property data has become somewhat of an industry standard. If you’ve had any interaction with working on a property website there’s a high chance you will have come into contact with it at some point.

Sending properties and constructing a feed is simple enough, but what if you need to parse a .blm feed. Maybe you’re building your own property portal or building an estate agent website that receives properties from a third party in this format. If so it can be challenging and time consuming to extract the data correctly, perform the relevant lookups, move images etc.

Introducing the CodeIgniter Library

This library will take a .blm file, or a ZIP file that includes the .blm, extract the data, move the images, floorplans etc to the specified directories, perform lookups on fields such as the property type, and will even archive it if required to a separate folder. The library is easy to use and I’ve also included extensive debugging so that you can see exactly where the issue lies should one arise. The result is an array of properties that you can then do with what you wish.

Downloading the Library

You can download the library by clicking the link below:

Download The Libary

The dowloaded ZIP file includes three files:

Rightmove_v3_parser.php – This file is the brains of the operation and is where all the magic happens. Simply place this straight into the ‘libraries’ folder of your application directory.

Unzip.php – This file is required if the .blm data feed and media will be provided in a zip. Again, place this file into the ‘libraries’ folder of your application directory.

sample.blm – A sample file to test the library.

Putting it into Action

Once the libraries have been put into place you’re ready to rock. I have included below a simple example to be placed in a controller that loads the library, sets a few optional parameters and processes the files:

// Load the library
// Set any required parameters
// file_name - (optional)
// If it is a specific file that you are looking to get processed
// enter the filename here. Can be a .blm or ZIP file. If no 
// filename is provided the library will use the last modified 
//file in the directory specified by the file_location parameter
$config['file_name'] = '';

// file_location - (optional)
// The directory where the files to be processed reside. If 
// blank the root directory shall be used
$config['file_location'] = '';

// image_destination - (optional)
// floorplan_destination - (optional)
// document_destination - (optional)
// epc_destination - (optional)
// hip_destination - (optional)
// The directories where the various media should be moved 
// to. If blank the media will not be moved
$config['image_destination'] = 'images';
$config['floorplan_destination'] = 'floorplans';
$config['document_destination'] = 'documents';
$config['epc_destination'] = 'epcs';
$config['hip_destination'] = 'hips';

// archive_location - (optional)
// If specified, the processed file will be moved here once 
// processing is completed
$config['archive_location'] = 'archived';
// Initialize the library
// Process the data feed and return the properties as an array
$data['properties'] = $this->rightmove_v3_parser->process();
// For debugging purposes output the results
echo $this->rightmove_v3_parser->print_debugger();
// Output the properties that have been processed

So there we have it. A whole data feed parsed in just a few lines of code. Please leave any feedback, bugs or change requests via the comments box below. Enjoy!

This entry was posted on Saturday, October 2nd, 2010 at 4:27 pm by +Steve Marks and is filed under PHP, Web Development. You can follow any responses to this entry through the RSS 2.0 feed.

Fear not, we won't publish this

Comments (24)
  1. Darren C says:

    I have actually figured this out now. What I do need, if anyone can help, is to create an xml document from the array that this class creates. Can anyone help?
    Many thanks

  2. Darren C says:

    This appears to be exactly what I need for a lettings website I have been asked to help with. However, I am struggling with the code above as I am not using codeigniter, I keep getting fatal errors – “Fatal error: Using $this when not in object context.” when trying to call Rightmove_v3_parser from a standard php page.
    I am fairly new to php, and would appreciate any help.

  3. You can put the BLM file wherever you like. Then set the ‘file_location’ option to specify where you put it.

  4. where i put .blm file like in which directory i put .blm file

  5. @Frank – There is a tutorial on the CodeIgniter user guide:

    Once you’ve got the grasp of controllers, then the code to go in the controller is supplied above in this post.

  6. Frank says:

    ok thanks well im new in programming, the question is hwo to create that controller there is any tutorial? do u have any example?
    can i contact you on facebook? here my email thanks

  7. Hello Frank. Glad to hear you found my CodeIgniter BLM library. To confirm, you need to put the files directly into your application ‘libraries‘ folder. Just the PHP files though. The sample.blm is there for your testing purposes and doesn’t belong in the ‘libraries‘ folder.

    As for the controller, this isn’t provided in the zip. You’ll have to create your own, then add the code from the post above into it.

    Hope that helps somewhat. Please let me know if any other questions.

    Thanks, Steve

  8. Frank says:

    hello im happy i found your libaries i did upload the libaries to the libraries floder but im not sure where to put it

    it this ok or should i just upload the files into libraries? 3 of them?

    controller that loads the library where can i found it?

    where do i place the code ?

  9. @Khaled – The idea is that the library parses the BLM file into a PHP array so you can then put it into your own database schema.

  10. Khaled says:

    Do you have a database scheme to go with this amazing lib?

  11. @Guy – The best thing I can suggest is that you set it up to run on a cron job (ie. automated task) at regular intervals.

  12. Guy says:

    Great thanks for this. This is what I needed.

    I have made a property site using wordpress. Vtuk are going to send the blm file over to my ftp server. Is there any kind of an event trigger when this happens that will make the parser know a new file has arrived and is to be processed?

  13. @haythem – Thanks for your message. The problem will be, as the error suggests, due to permissions in that the unzipping library doesn’t have access to the folder where the BLM file will reside. Without seeing your directory it’s hard to give anymore infomation. If you still have problems after playing with permissions, please feel free to email me the code that you are currently using and your directory structure and I’ll be happy to take a closer look.

    Good luck!

  14. haythem says:

    i’m having a problem using this library. it works great with the .blm file but i get this error with the .zip file :

    A PHP Error was encountered

    Severity: Warning

    Message: file_put_contents(./sample.blm): failed to open stream: Permission denied

    Filename: libraries/Unzip.php

    Line Number: 376
    A PHP Error was encountered

    Severity: Warning

    Message: chmod(): Operation not permitted

    Filename: libraries/Unzip.php

    Line Number: 305

    Rightmove_v3_parser Class Initialized
    File appears to be a zip. Extracting files…
    Extracted files successfully
    Unable to open file location () to get unzipped blm file to process
    Reading file contents
    Header Property Count set as zero
    Processing complete

    Array ( )

  15. Hi Martin, Thanks for getting in touch. You certainly can modify the library to disregard the property count in the header. Thinking about it, it’s probably a little too strict anyway so I might change this to be an optional setting in the future. Regardless, for the time being you can simply comment out lines 316 and 330 in the library (Rightmove_v3_parser.php) to get this to work.

    Give me a shout if you need any further help with this. Thanks again, Steve

  16. I’m having a problem using this library. It works great, except for vendors who don’t provide the property count field in the file header.

    As it’s not deemed mandatory by Rightmove, the vendors I’m working with are not interested in adding this field as it’s obviously a cost to them for no immediate monetary return, no matter how trivial it is to just add one field their side.

    So my question is: can the Rightmove library be modified so that it continues to parse property entries, even if the property count field is omitted in the BLM file?

  17. @Derek – Thanks for the kind words. Glad to hear that the library was of some use to you.

    Reference how it would work 99% of portals work by, as you say, receiving the BLM (or ZIP containing the BLM) via FTP. Each data provider has their own FTP directory so they can’t see data from other data providers. Then every so often the portal (20-30 minutes in Rightmoves case) polls the directory to see if any files are waiting to be processed.

    I hope that’s of some use, however give me a shout if you need any more info. Cheers, Steve

  18. Derek says:

    what an awesome class you have written!

    Thanks for this! I don’t use codeigniter but a few tweaks later and I’m now on the way!

    Just a quick question if you could help?
    I’ve never worked on a property portal before (until last week, now were making one :-s ) and we’re supposed to be accepting these feeds.. could you quickly outline whats happening on the server?

    so far (from what i hear) it sounds like these blm’s are supposed to be ftp’d to a folder, is that right? it doesn’t sound right! and then what, i take it a cron would need to run?

    what im saying is, how does the server get these zips/blms and say ‘ah, time to run your class!’ ?
    If you could even just point me in the right direction? you have already saved my bacon today ;-)

    Cheers again Steve!
    Derek :-)

  19. Ben Hunt says:

    Hi, has anybody had any experience tying this in to expression engine 2.0 which runs on the codeigniter platform?

  20. @David – Hope this can be of some use to you :) If you get stuck or need any modifications please give me a nudge and I’ll see what I can do to help. Enjoy!

  21. David says:

    Really useful read, as i’m working on a property website, i hope it’s not too difficult to implement!

  22. @Scott – Could be that you’re using CodeIgniter 2.0 whereas the example shown used 1.7 due to the time of writing. I have removed the version specific parts of the example and included just the bits and are relevant to the library. Let me know if you continue to experience problems and I’ll see what I can do. Thanks for letting me know

  23. Scott says:

    Getting the following error;

    Fatal error: Class ‘Controller’ not found

    # Time Memory Function Location
    1 0.0008 372864 {main}( ) ..\output.php:0

  24. Naweed says:

    This is the article I was looking for over the weeks. Nice explanation and crystal clear coding sample. Thanks for posting, I’d like to bookmark it in my browser.