Im trying to load the following XML url and some data within into my database.
https://zkillboard.com/api/kills/corporationID/98115872/pastSeconds/7200/xml/
i have the following code:
<?php
// INCLUDE DB CONNECTION FILE
include("includes/connect.php");
// CHANGE THE VALUES HERE
include("includes/config.php");
$url = "https://zkillboard.com/api/kills/corporationID/98115872/pastSeconds/7200/xml/";
// RUN XML DATA READY FOR INSERT
$xml = simplexml_load_file($url);
// Loop Through Names
$insertValues = array();
$modifiedTS = date('Y-m-d h:i:s');
foreach ($xml->result->rowset[0] as $value)
{
//Prepare the values
$killID = $value['killID'];
$solarSystemID = mysql_real_escape_string($value['solarSystemID']);
$killTime = $value['killTime'];
$moonID = $value['moonID'];
$allianceName = $value['allianceName'];
$corporationName = $value['corporationName'];
$damageTaken = $value['damageTaken'];
//Create and run ONE INSERT statement (with UPDATE clause)
$insert = "INSERT INTO `killLog` (killID,solarSystemID,killTime,moonID,allianceName,corporationName,damageTaken,last_modified) VALUES('$killID','$solarSystemID','$killTime','$moonID','$allianceName','$corporationName','$damageTaken','$modifiedTS') ON DUPLICATE KEY UPDATE
last_modified = '$modifiedTS'";
mysql_query($insert) or die(mysql_error());
};
?>
but i get the following errors when accessing the PHP file.
Warning: simplexml_load_file(https://zkillboard.com/api/kills/corporationID/98115872/pastSeconds/7200/xml/) [function.simplexml-load-file]: failed to open stream: HTTP request failed! HTTP/1.1 406 Non-acceptable encoding. Please use gzip or deflate in /homepages/*****/*****/htdocs/*****/tool/admin/api_killLog.php on line 14
Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "https://zkillboard.com/api/kills/corporationID/98115872/pastSeconds/7200/xml/" in /homepages/*****/*****/htdocs/*****/tool/admin/api_killLog.php on line 14
Warning: Invalid argument supplied for foreach() in /*****/*****/htdoc/*****/tool/admin/api_killLog.php on line 19
what am i doing wrong??