map2

Documentation

Marknadsdatabasen
Import-API

Updating the MdB via API is a simple way to automate this otherwise laborious task. Please work with people experienced in communicating with API's online. Each API session needs to be authenticated using documentation AXA: Atlas XML API, and all data sent with this API must be encoded as UTF8.
Please mind that all API requests are sent to one web server, meaning that if you have child sites, you need to use the URL for each child site. A communication operator with four sites will this need to run this API on four different URL's

Here is some example PHP code for using insert_posts():

$api_user = 12345; $api_key = "xxx"; $api_hash = ""; require_once 'Zend/Rest/Client.php'; $client = new Zend_Rest_Client("http://www.example.com/admin/edit/mdb_buildings/plain/api.php"); $client->api_login($api_user, $api_key); $login = $client->get(); $api_hash = $login->hash_key->__toString(); $keys = array("coId", "accessId", "...", "residentName", "activeServices"); $apifile = "addresses.csv"; if (($handle = fopen($apifile, "r")) !== false){         $nr = 0;         while (($csv = fgetcsv($handle, 1000, $delimiter)) !== false){                 $nr++;                 $data = array_combine($keys, $csv);                 $inserts["line$nr"] = $data;                 if ($nr % 100 == 0){                         $status = insert_posts($inserts);                         if (!$status->status == "success") unset($inserts);                         print "$nr: " . $status->message . "n";                         if ($status->log){                                 foreach ($status->log as $line => $errors){                                         if (strstr($errors, "successfully")) continue;                                         print "   $line: $errorsn";                                 }                         }                 }         }         if ($inserts){                 $status = insert_posts($inserts);                 print "$nr: " . $status->message . "n";                 if ($status->log){                         foreach ($status->log as $line => $errors){                                 if (strstr($errors, "successfully")) continue;                                 print "   $line: $errorsn";                         }                 }         } } function insert_posts($inserts){         global $client, $api_hash;         $client->insert_posts($api_hash, $inserts);         try{                 $inserted = $client->post();                 return $inserted;         } catch (Zend_Rest_Client_Result_Exception $e){                 print $e->getMessage() . ": " . $e->getCode() . "nn";         } }

Timing

It is our explicit recommendation that you run your import script during the timeframe between midnight to 7 am in the morning. The reson for this is that we run an aggregation script for XSP export at 7 am, and if you have run your import, the daily data will include that for the service providers in the following day.
Another reason is that if you were to run this during daytime, and you empty the database and insert every row, then you'd have a empty or incomplete database during a time where end customer could be searching for their address. Also, during nighttime the resource pressure on the server is much lower.
View API specification View API specification