FinWX Foorumi

Yleiset keskustelualueet => EWN - European Weather Network => Aiheen aloitti: weatherc - lauantai, 02.11.2013, 13:49

Otsikko: Tieinfo alhaalla
Kirjoitti: weatherc - lauantai, 02.11.2013, 13:49
Tieinfo näytää olevan alhaalla joten Suomen tiesäädata ei ole päivittynyt sitten eilisen...
Otsikko: Vs: Tieinfo alhaalla
Kirjoitti: ARu - perjantai, 09.05.2014, 16:07
Eipä oo toiminut taas muutamaan päivään, ei ainakaan sivuille tuu tietoa.
Otsikko: Vs: Tieinfo alhaalla
Kirjoitti: weatherc - perjantai, 09.05.2014, 17:43
Kyllä ainakin seuraava puskee dataa:
http://tieinfo.mustcode.fi/tieinfo/liikenne/tiedotteet/?json
Otsikko: Vs: Tieinfo alhaalla
Kirjoitti: ARu - perjantai, 09.05.2014, 17:48
ei tällä tuu mitään
http://tieinfo.mustcode.fi/tieinfo/saa/paikkakunta/joutsa?json
Otsikko: Vs: Tieinfo alhaalla
Kirjoitti: weatherc - perjantai, 09.05.2014, 17:58
Huomasin juu kun kokeilin hakea säätietoja. Säätiedot näyttää olevan alhaalla.
Otsikko: Vs: Tieinfo alhaalla
Kirjoitti: ARu - perjantai, 30.01.2015, 15:09
taitaa olla tieinfo lopettanut kun ei oo toiminut vähään aikaan.
ei muuten mutta kun en osaa laittaa noita fmi:n tiesää arvoja sivuille.
Otsikko: Vs: Tieinfo alhaalla
Kirjoitti: weatherc - sunnuntai, 01.02.2015, 13:06
Tuolla sen datan saa hauettua suoraan Digitrafficista/Liikennevirastolta:


<?php

//Soap-URL
$soapUrl "http://open.digitraffic.fi/services/roadWeather"// asmx URL of WSDL

// xml post
$xml_post_string '<?xml version="1.0" encoding="utf-8"?>

  <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sch="http://www.gofore.com/sujuvuus/schemas">
  <soapenv:Header/>
  <soapenv:Body>
  <sch:RoadWeather/>
  </soapenv:Body>
  </soapenv:Envelope>';

$headers = array(
  "DT-User-Agent: test",
  "DT-Contact-Info: me"
  );
$rfi = "/home/xxx/xxx/cache/roadWeather.soap";

if (file_exists($rfi) and (filemtime($rfi) + 600) > time()) {
  $response = file_get_contents($rfi);
}else{
  // PHP cURL
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $soapUrl);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_TIMEOUT, 10);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string);
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  $response = curl_exec($ch);
  curl_close($ch);
  file_put_contents($rfi, $response);
  chmod($rfi, 0666);
}

$response1 = str_replace("<soap:Body>","",$response);
$response2 = str_replace("</soap:Body>","",$response1);
$parser = simplexml_load_string($response2);
$array = json_decode(json_encode((array)$parser), TRUE);
$data = $array[RoadWeatherResponse][roadweatherdata][roadweather];


?>