Retrieving Feed in WordPress
Stap 1: Install WP Crontrol : https://wordpress.org/plugins/wp-crontrol/
Step 2: Navigate to tools->Cron Events -> Add php Cron Event
Copy the code below and insert this code in the PHP code field in wp crontrol You can select the interval, the interval determines how often you will retrieve te feed. We advise setting the interval to 1 day. Running this cronjob will create a csv file inside your uploads folder: uploads/livingfurn/feed.csv Using this file you can setup this information any way you'd like.
Dont forget to insert the login authentication (replace xxxxxxxxxx with your api token).
// API token:
$authentication = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
if ( ! is_dir( WP_CONTENT_DIR . '/uploads/livingfurn/' ) ) {
mkdir( WP_CONTENT_DIR . '/uploads/livingfurn/', 0700 );
}
$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_put_contents( WP_CONTENT_DIR . '/uploads/livingfurn/feed.csv', $response );
}
Contact raymond@livingfurn.nl for your personal login credentials.