<?php
 
        
// input variabelen
        
$myDatafileLocation "http://www.m4n.nl/_df/stream-13152-2421.csv?duid=2421&dhid=5B19&dfid=13152&m=csv&sep=tab1&valq=value2&max=10";
        
        
// The update date of your current data is 01 Jan 1970; expected outcome is 200 OK since the m4n update date is more recent. 
        
$myUpdateTime strtotime("Fri, 01 Jan 1970 03:13:32 GMT");
        
// The update date of your data is the current date. The date of the M4N data will be older; therefore you will get no data back and a 304 Not modified status message
        
$myUpdateTime time();
                
        
// create curl resource
        
$ch curl_init();
 
        
// set url
        
curl_setopt($chCURLOPT_URL$myDatafileLocation);
 
        
//return the transfer as a string
        
curl_setopt($chCURLOPT_RETURNTRANSFER1);
        
        
curl_setopt($chCURLOPT_HEADER);
        
curl_setopt($chCURLOPT_TIMECONDITIONCURL_TIMECOND_IFMODSINCE );
        
curl_setopt($chCURLOPT_TIMEVALUE$myUpdateTime); 

 
        
// $output contains the output string
        
$output curl_exec($ch);
        
$statusCode curl_getinfo($chCURLINFO_HTTP_CODE);
 
        
// close curl resource to free up system resources
        
curl_close($ch);
        
        switch (
$statusCode) {
    case 
200:
        
?>
        De data is succesvol binnengehaald met status <? echo $statusCode?>. Dit houdt in dat de feed <a href="<? echo $myDatafileLocation?>" target="_blank"><? echo $myDatafileLocation?></a> ververst is. De waarde $output bevat content die verwerkt kan worden in je database.
        <?
        
break;
        case 
304:
        
?>
        De data is gecheckt waarbij de server status <? echo $statusCode?> terug gaf. Dit houdt in dat de feed <a href="<? echo $myDatafileLocation?>" target="_blank"><? echo $myDatafileLocation?></a> sinds laatste update NIET is ververst. De waarde $output bevat GEEN content; op dit punt moet je voorkomen dat de bestaande data in je database wordt verwijderd.        
        <?
        
break;
        }
 
?>
<br><hr><br>
<? echo $output?>