Step 1: Create a new folder on your hosting, we advise naming this folder CSV. In this folder you create a new file called readcsvfeed.php
Step 2: Insert the code as seen below, The livingfurnlocation and authentication values will be provided by livingfurn.
$authentication = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
Step 3: Insert the code as seen below. the filename variable is the name of the file that will be filled with up to date information from the feed.
$folder = getcwd();
$filename = "livingfurn.csv";
Step 4: Add the code below:
// == STEP 6 DELETE THIS IN STEP 6
$croncommand = exec("which php") . ' ' . getcwd() . '/readcsvfeed.php';
echo($croncommand);
// == STEP 6 DELETE THIS IN STEP 6
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://feed.livingfurn.nl/api/feed",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer $authentication",
"Cache-Control: no-cache",
"Connection: keep-alive",
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
$file = $folder. '/' . $filename;
file_put_contents($file, $response . "\n");
}
Step 5: Call readcsvfeed.php on your website, if you placed your readcsvfeed.php file in a folder called csv in the root of your domain then you can access it like this: www.yoursite.com/csv/readcsvfeed.php. After calling this file you need to verify if the CSV file is placed inside the same csv folder you created in step 1. When calling readcsvfeed.php you will see a command which you can setup inside a cron command. Using a cron command you can periodically call the readcsvfeed.php file and as such, refresh the csv file on your server. Are you using directadmin? Click here for more information : https://dutchwebhosting.nl/handleidingen/directadmin/25-een-cronjob-aanmaken.php
step 6, after installing cron you can delete the code which should be deleted in step 6. ( // == STAP 6 delete this in step 6 )
After going trough all the steps your readcsvfilefeed.php should look like this ( your own variables and folder setup not included )
<?php $authentication = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$folder = getcwd();
$filename = "livingfurn.csv";
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://feed.livingfurn.nl/api/feed",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer $authentication",
"Cache-Control: no-cache",
"Connection: keep-alive",
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
$file = $folder. '/' . $filename;
file_put_contents($file, $response . "\n");
}