I was recently working on another Codeigniter project that I needed to grab some phone, address, & map information for plotting on a map. After doing a little searching I found Whitepages.com has provided an API interface for retrieving data via REST. The methods seemed simple enough, and provided an easy way to create a CodeIgniter library to due the dirty work.The library is pretty straightforward and includes good easy to read documentation. You can receive data in either XML or in JSON format. I’ve included for demo purposes a SimpleXML codeigniter library to parse and convert the XML to an associative array. You can view the controller to see how this was implemented.
As shown in the readme docs, the class is easy to use. Example:
$info = array('lastname' => 'Smith', 'firstname' => 'John'); $data['xml'] = $this->whitepages_lib->find_person($info); |
This will search using the find_person method of the API for the name “John Smith”. You can pass any of the fields shown in the documentation in your associative array.