Visualizzazione dei risultati da 1 a 2 su 2

Discussione: Conversione script

  1. #1

    Conversione script

    Non so se sono nella sezione giusta, ma avrei veramente bisogno che qualcuno mi convertisse il seguente script da PHP a ASP..


    <?php

    $location = $_GET['location'];
    $metric = (int)$_GET['metric'];

    $url = 'http://rainmeter.accu-weather.com/widget/rainmeter/weather-data.asp?location=' . $location . '&metric=' . $metric;

    $ch = curl_init();
    $timeout = 0;
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    $file_contents = curl_exec($ch);
    curl_close($ch);

    $xml = simplexml_load_string($file_contents);

    $weather['city'] = (string)$xml->local->city;
    $weather['curr_temp'] = (int)$xml->currentconditions->temperature;
    $weather['curr_text'] = (string)$xml->currentconditions->weathertext;
    $weather['curr_icon'] = (int)$xml->currentconditions->weathericon;

    // forecast
    $day = count($xml->forecast->day);
    for ($i = 0; $i < $day; $i++) {
    $weather['forecast'][$i]['day_date'] = (string)$xml->forecast->day[$i]->obsdate;
    $weather['forecast'][$i]['day_text'] = (string)$xml->forecast->day[$i]->daytime->txtshort;
    $weather['forecast'][$i]['day_icon'] = (int)$xml->forecast->day[$i]->daytime->weathericon;
    $weather['forecast'][$i]['day_htemp'] = (int)$xml->forecast->day[$i]->daytime->hightemperature;
    $weather['forecast'][$i]['day_ltemp'] = (int)$xml->forecast->day[$i]->daytime->lowtemperature;
    }


    echo json_encode($weather);



    ?>


    serve per recuperare info meteo dallo scirpt jdigiclock.

    grazie a chi mi aiuterà..

  2. #2
    Dovresti postarlo nella parte ASP.
    Ce l'ho fatta! - ItalianPixel -

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.