⬆️ ⬇️

Creating a database based on API 37signals

One of our services builds daily reports by analyzing data from Highrise .

Data from Highrise can be obtained in several ways:



CSV was not even considered by us and we tried to find a convenient method for daily updating our database through the API.

Come up with the following:





Sample XML response (https://xxx.highrisehq.com/deals.xml):



image



The arrows indicate the elements that we consider nested and, accordingly, bring the data into related tables.

')

As we did from XML MySQL tables.






An example of what we get at the output:



image



Now you can do anything with this data, draw graphs, count amounts, pull out other interesting information.



Most importantly, the resulting code works with all 37signals services and can synchronize any of their services.



Basecamp synchronization example




<?php require 'SyncService.class.php'; $sync = new SyncService( array( 'db' => array( 'host' => 'localhost', 'user' => 'root', 'password' => '123', 'schema' => 'basecamp' ), 'service' => array( 'name' => 'basecamp', 'url' => 'https://xxx.basecamphq.com', 'token' => 'abcdef1234567890abcdef1234567890', 'streams' => array( '/todo_lists.xml' => 500, '/people.xml' => 500, '/projects.xml' => 500, '/account.xml' => 0, ) ), ) ); $sync->doSyncing(); 




All library code along with an example on a githab.

Source: https://habr.com/ru/post/179665/



All Articles