iwato Posted November 14, 2018 Share Posted November 14, 2018 BACKGROUND: Between one and two moons ago I inquired about a strategy for speeding up my Matomo processing time, whereupon both Funce and Dsonesuk provided excellent insight in this regard. I am now on the verge of setting up a CRON Job to perform scheduled calls to the Matomo data base. Before implementing the scheduler, however, I must be clear about the format that I am to use to handle the data. As I am provided with a variety of formats, I decided to explore those that I thought would be useful before deciding on one. To my dismay I am overwhelmed with what I discovered. Both of the following responses represent the first few lines of the same cURL request. The only change when making these requests was the indicated formats. The problem is that I have no idea how to handle data in these formats. PHP a:100:{ i:0;a:96:{ s:6:"idSite";i:1; s:7:"idVisit";i:914; XML 1 914 205.175.107.119 ... action http://www.grammarcaptive.com/podcast_hostpage.php?hash=30a6836a3f7c5fc57751a61098e5c2fc&podcast_no=92 Grammar Captive Weekly Podcasts 14 wYBSoJ Nov 14, 2018 08:47:46 25338 25 25s 1824 1.82s 1 1542185266 action https://www.grammarcaptive.com/overview.html Grammar Captive Overview 6 CLxGe9 Nov 14, 2018 08:48:11 25339 1 1s 2419 2.42s 2 1542185291 action http://grammarcaptive.com/_gates/gate1/gate1.html Gate One - What Makes Grammar Captive Different 33 aXaszd Nov 14, 2018 08:48:12 25340 0 0s 262 0.26s 3 1542185292 action https://www.grammarcaptive.com/_gates/gate3/gate3.html Gate Three - Is Grammar Captive for You? 50 The three dots (...) represent sensitive data values. The indendation and line spacing was added by me. Although the first set of data resembles very closely that of JSON, the second set of data is completely lacking in the metadata required to understand what is being returned. Unfortunately, I have no idea how to handle either in the given formats. Please advise. Roddy Link to comment Share on other sites More sharing options...
justsomeguy Posted November 14, 2018 Share Posted November 14, 2018 The first one is a serialized array. The second is useless without knowing what the fields are. Link to comment Share on other sites More sharing options...
Ingolme Posted November 14, 2018 Share Posted November 14, 2018 To be certain, I would need to see documentation about the web service that you are making requests to. The first item is a serialized PHP data structure, you convert it back into data using the unserialize() function. I am willing to bet that the second item is XML, but since you have loaded it into a browser, the tags are being parsed and only the text content is being shown. If you want to actually see the XML tags in the browser, you either have to send a "text/xml" content type header or pass the data through htmlspecialchars(). While seeing the data is useful for debugging, ultimately, you don't really want to do that. What you should do with the XML response is create a DOMDocument for it so that you can retrieve the data contained within it. 1 Link to comment Share on other sites More sharing options...
Funce Posted November 15, 2018 Share Posted November 15, 2018 (edited) Taking a look through the Matomo docs also reveals JSON to be a valid alternative. I would recommend it due to its simplicity. json_decode() is an inbuilt function specifically for dealing with JSON. Edited November 15, 2018 by Funce Link to comment Share on other sites More sharing options...
iwato Posted November 16, 2018 Author Share Posted November 16, 2018 Thank you all, but especially Ingolme, for she answered my question in the most thorough manner possible. I am currently testing Peppe Occhi's CRON Scheduler routine and have yet to decide whether I will take Funce's suggestion to pass my results to a database or Dsonesuk's suggestion to write to an XML file. After all this time, I am still not comfortable with the data that I am able to extract from the Matomo data base via its reporting APIs, and more research is still ahead before I can decide how to fetch and store the data on a routine basis. At least now I know better what my options are and how to proceed with them once I have decided. Have a great weekend. Mine will be spent on the internet, as nearly always until I have launched. Roddy 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now