My first post so please be kind, or not if thats how it works around here. I have a simple script making an API call to retrieve the data of an error log, and using the $_GET method to call the url inside the script as I plan in the future to run this as part of a bigger script that will run via a cron.
The problem I am having is when the data is displayed it is just a huge mess of a wall of text not formatted in the slightest way. Each line in the error log begins with a date, and time.
Here is a small sample of the output.
{"type":"success","response":{"data":{"thispage":1,"totalpages":1,"log":"2015-03-09 08:16:28\tINFO\t[ADMINCGI] XML title update [<?xml version=\"1.0\" encoding=\"UTF-8\" ?><metadata><TIT2>Title of Stuff - Book Stuff\n<\/TIT2><\/metadata>]\n2015-03-09 08:20:01\tINFO\t[ADMINCGI] XML title update [<?xml version=\"1.0\" encoding=\"UTF-8\" ?><metadata><TIT2>Another TItle of Stuff - Music Title\n<\/TIT2><\/metadata>]\n2015-03-09 08:25:40\tINFO\t[ADMINCGI] XML title update [<?xml version=\"1.0\" encoding=\"UTF-8\" ?><metadata><TIT2>Holy Cow - Title of CD\n<\/TIT2><\/metadata>]\n2015-03-09 08:31:33\tINFO\t[ADMINCGI] XML title update [<?xml version=\"1.0\" encoding=\"UTF-8\" ?><metadata><TIT2>The pizza king - eat pizza\n<\/TIT2><\/metadata>]\n2015-03-09 08:35:56\tINFO\t[ADMINCGI] XML title update [<?xml version=\"1.0\" encoding=\"UTF-8\" ?><metadata><TIT2>Ouch - Ouch Ouch\n<\/TIT2><\/metadata>]\n2015-03-09 08:40:19\tINFO\t[ADMINCGI] XML title update [<?xml version=\"1.0\" encoding=\"UTF-8\" ?><metadata><TIT2>What shall I do - Dump\n<\/TIT2><\/metadata>]\n2015-03-09 08:45:59\tINFO\t[ADMINCGI] XML title update [<?xml version=\"1.0\" encoding=\"UTF-8\" ?><metadata><TIT2>Its not a hangover - its cancer\n<\/TIT2><\/metadata>]\n2015-03-09 08:49:31\tINFO\t[ADMINCGI] XML title update [<?xml version=\"1.0\" encoding=\"UTF-8\" ?><metadata><TIT2>something is going on here - lalala\n<\/TIT2><\/metadata>]\n
But of course it is in a huge wall of many lines of that. How do I parse that so that each line begins with the date and time of each new item?
Here is the php code with a sprinkle of javascript I am using, that results in the above.
<script>
javascript:void(location.href="http://url:port/api.php?xm=server.readlogs&f=json&a[username]=pizzaman&a[password]=THEpassword&a[type]=error");
</script>
<?php
$output = $_GET["a[type]"];
echo $output;
?>
Thanks in advance for everyones help