[insert_php]
if(isset($_POST[‘GrabPrice’]))
{
//include_once “config.php”;
//include(‘wp-content/config.php’);
define(“dbhost”, “localhost”);
define(“dbuser”, “i4632162_wo1”);
define(“dbpass”, “C.SYOmwxPaG6rwGrACH83”);
define(“db”, “i4632162_wo1”);
// function to upload file and read the components.
//code begins
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, “https://baroxx.preiseule.com/pr/access-token-baroxx-877b9c99-5bb6-47c8-8546-95537a43bd6b/export_noywe87hw”);
$agent= ‘Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)’;
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15); //time out of 15 seconds
$output = curl_exec($ch);
curl_close($ch);
$conn = mysqli_connect(dbhost, dbuser, dbpass, db);
$arr = json_decode($output, true);
foreach ($arr as &$value)
{
$PID = “1000”.$value[‘product_id’];
$PURL = $value[‘url’];
$Pfaulttimestamp = date(“Y-m-d”, $value[‘fault_timestamp’]);
$Ppricetimestamp = date(“Y-m-d”, $value[‘price_timestamp’]);
$Pfault = $value[‘fault’];
$Price = $value[‘price’];
$PCode = $value[‘product_code’];
$PName = $value[‘product_name’];
$PShopName = $value[‘shop_name’];
$Pfaultmessage = “”;
$country_Code = “DE”;
$Ppravailable= “1”;
if ($conn )
{
$sql = “INSERT INTO PR_PRICE_HIST_TBL (PR_PRODUCT_ID, PR_URL_ID, PR_LAST_CHECKED, PR_LAST_PRICE, PR_COUNTRY_CODE, PR_AVAILABLE, PR_DOMAIN, PR_FAULT_FLAG, PR_FAULT_TIME,PR_FAULT_MSG) VALUES (‘$PID’,’1′, ‘”01-JAN-2018″‘,’$Price’,’$country_Code’,’$Ppravailable’,’$PShopName’,’$Pfault’,’$Pfaulttimestamp’,’$Pfaultmessage’)”;
$result=$conn->query($sql);
error_log($conn->error);
//echo $result, “+++++++++++++++++++++” , $PURL, “
“;
}
//echo “Hello”;
}
}
[/insert_php]