Demo: Hent neste arrangement i krets fra Eventor

"; # Get data from Eventor $fromDate=date("Y-m-d"); # From today $toDate=date("Y-m-d",time()+86400*60); # Next 60 days $url = EVENTOR_API_BASE_URL . "events?fromDate=".$fromDate."&toDate=".$toDate."&organisationIds=$orgID"; $xml = eventorApiCall($url); $doc=simplexml_load_string($xml); $ii=0; $eventNodes = $doc->xpath("//Event"); # Sort events on date function sort_events($t1, $t2) { $d1=$t1->xpath('StartDate/Date'); $d2=$t2->xpath('StartDate/Date'); return strcmp($d1[0], $d2[0]); } usort($eventNodes, 'sort_events'); # Go through each event, and print it out foreach($eventNodes as $eventNode) { $EventId=$eventNode->xpath("EventId"); $Name=$eventNode->xpath("Name"); $Date=$eventNode->xpath("StartDate/Date"); $Clock=$eventNode->xpath("StartDate/Clock"); $OrgID=$eventNode->xpath("Organiser/OrganisationId"); $ii++; if ($ii<=$maxentries) { list ($hour,$min,$sec)=split(":",$Clock[0]); if ($hour=="00" && $min=="00") { $starttime="";} else { $starttime=" (".$hour.":".$min.")";} list($year,$mon,$day)=explode('-',$Date[0]); $link="http://eventor.orientering.no/Events/Show/".$EventId[0]; $data.= "".sprintf("%02d.%02d",$day,$mon)."$Name[0]$starttime"; } } $data.= ""; # Write to cachefile $cachefile = fopen($cache, 'wb'); fwrite($cachefile, $data); fclose($cachefile); } # Get data from cache file if necessary if (!$data) { $data = file_get_contents($cache); } print $data; function eventorApiCall($url) { // create curl resource $ch = curl_init(); // set url curl_setopt($ch, CURLOPT_URL, $url); // return the transfer as a string curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // set header curl_setopt($ch, CURLOPT_HTTPHEADER, array("ApiKey: " . EVENTOR_API_KEY)); // $output contains the output string $output = curl_exec($ch); // close curl resource to free up system resources if(curl_errno($ch)) { # print "Error: ".curl_errno($ch)."

"; } curl_close($ch); return $output; } ?>