Kodları lütfen aşağıdaki butonları kullanarak renklendirin. Örnek: <php> echo "Selam Dünya"; </php>
Yardım
karakter kaldı

php kodlarını c# a çevirme

Merhabalar ;
Arkadaşlar aşağıdaki hava durumu için yazılmış kodları php den c# a çevirebilecek biri var mı acaba ?

<?php
$placename = 'İstanbul'; // city where you want local weather
$place=urlencode($placename);
$place = utf8_encode($place);
$url = 'http://www.google.com/ig/api?weather='.$place.',$&hl=tr';
$ch = curl_init();
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 0);
$raw_data = curl_exec ($ch);
curl_close ($ch);

$xml = simplexml_load_string($raw_data);
$condition = $xml->weather->current_conditions->condition['data'];
$temp_c = $xml->weather->current_conditions->temp_c['data'];
$humidity = $xml->weather->current_conditions->humidity['data'];
$icon = $xml->weather->current_conditions->icon['data'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery Weather</title>
<link rel="stylesheet" type="text/css" href="css/reset.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script src="js/jquery.scrollTo-1.3.3.js" type="text/javascript"></script>
<script src="js/jquery.localscroll-1.2.5.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.serialScroll-1.2.1.js" type="text/javascript" charset="utf-8"></script>
<script src="js/coda-slider.js" type="text/javascript" charset="utf-8"></script>
</head>

<body>
<div id="wrapper" title="Herhangi bir gün seçebilirsiniz">
<div id="weatherBg">
<div class="scroll">
<div class="scrollContainer">
<?php for ($i = 0; $i < count($xml->weather->forecast_conditions); $i++){
$data = $xml->weather->forecast_conditions[$i];
?>
<div id="<?php echo $data->day_of_week['data']; ?>">
<div class="todayWeather">
<div class="todayImage"> <img src="
<?php
$old = array('/ig/images/weather/');
$new = array('images/weather/');
$img = str_replace($old,$new,$data->icon['data']);
$old = array('.gif');
$new = array('.png');
$img = str_replace($old,$new,$img);
echo $img; ?>"
alt="<?php echo $data->condition['data']; ?>" height="80" width="120" /></div>
<div class="todayCondition">
<h1 class="city"> <?php echo $placename; ?></h1>
<h2 class="temp"> <?php echo $data->low['data']; ?> &deg;C | <?php echo $data->high['data']; ?> &deg;C </h2>
<h3 class="conditionData"> <?php echo $data->condition['data']; ?></h3>
</div>
</div>
</div>
<?php } ?>
</div>
<!-- end scroll -->
</div>
<!-- end scrollContainer -->

<div id="forecast">

<?php for ($i = 0; $i < count($xml->weather->forecast_conditions); $i++){
$data = $xml->weather->forecast_conditions[$i];
?>
<div class="weather" >
<div class="weatherDay"> <a href="#<?php echo $data->day_of_week['data']; ?>"> <?php echo $data->day_of_week['data']; ?> </a> </div>
<div class="weatherImage" > <img src="
<?php
$old = array('/ig/images/weather/');
$new = array('images/weather/');
$img = str_replace($old,$new,$data->icon['data']);
$old = array('.gif');
$new = array('.png');
$img = str_replace($old,$new,$img);
echo $img; ?>" width="35" height="25" alt="<?php echo $data->condition['data']; ?>" /> </div>
</div>
<?php } ?>

</div> <!-- end forecast -->

</div> <!-- end weatherBg -->

</div> <!-- end wrapper-->
</body>
</html>
+0
-0
Cevaba KatılıyorumKatılmıyorum
Cevap Yaz Yorum Yaz Arşivime Ekle Takip Et

Cevaplar

  • freefox adlı üyenin fotoğrafı
    12 yıl önce yazılmış
    37 cevap - 21 soru
    php kodlarını c# çevirmekten daha mantıklısı online xml veya json olarak havadurumu bilgilerini veren siteleri kullanmaktır.
    yada hiç olmadı bu php kodundan xml çıktı üretip c# la okutabilirsin
    • imeilim adlı üyenin fotoğrafı imeilim
      öncelikle cevabınız için çok teşekkürler.
      Elimdeki script çok güzel efektli filan güzel bir hava durumu isterseniz gönderebilirim hazır servisler yerine bunu kullanmak isterim.
      Ancak dediğiniz olayı yani phpden xml çıktı almayı da malesef nasıl yapılacağını bilmiyorum.
      Neyse yine de çok teşekkürler..
      12 yıl önce yazılmış
  • Supervisor adlı üyenin fotoğrafı
    12 yıl önce yazılmış
    107 cevap - 0 soru
    google wheather apisini kullanarak aliyosun. buyur burda c# ta nasil kullanacagin.

    http://www.dreamincode.net/forums/topic/153911-using-google-weather-api-in-a-c%23-application/
    • imeilim adlı üyenin fotoğrafı imeilim
      Yapamadım ya bir türlü.
      İyi anlayan bir arkadaş çevirse şunu eminim birçok kişinin işine yarar.
      12 yıl önce yazılmış
  • bluedolphins adlı üyenin fotoğrafı
    1 yıl önce yazılmış
    1 yıl önce güncellenmiş
    1 cevap - 0 soru
    wwww.bluedolphins.com.tr

    using System;
    using System.IO;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Web;
    using System.Web.Mvc;
    using System.Reflection;
    using runnerDotNet;
    namespace runnerDotNet
    {
    public partial class GlobalController : BaseController
    {
    public XVar code()
    {
    try
    {
    dynamic ch = null, condition = null, data = null, humidity = null, i = null, icon = null, img = null, old = null, place = null, placename = null, raw_data = null, temp_c = null, url = null, var_new = null, xml = null;
    placename = new XVar("İstanbul");
    place = XVar.Clone(CommonFunctions.urlencode((XVar)(placename)));
    place = XVar.Clone(CommonFunctions.utf8_encode((XVar)(place)));
    url = XVar.Clone(MVCFunctions.Concat("<a href="http://www.google.com/ig/api?weather="" target="_blank" class="external" rel="nofollow">http://www.google.com/ig/api?weather="</a>, place, ",$&hl=tr"));
    ch = XVar.Clone(CommonFunctions.curl_init());
    CommonFunctions.curl_setopt((XVar)(ch), new XVar(Constants.CURLOPT_RETURNTRANSFER), new XVar(1));
    CommonFunctions.curl_setopt((XVar)(ch), new XVar(Constants.CURLOPT_URL), (XVar)(url));
    CommonFunctions.curl_setopt((XVar)(ch), new XVar(Constants.CURLOPT_USERAGENT), (XVar)(MVCFunctions.GetServerVariable("HTTP_USER_AGENT")));
    CommonFunctions.curl_setopt((XVar)(ch), new XVar(Constants.CURLOPT_TIMEOUT), new XVar(60));
    CommonFunctions.curl_setopt((XVar)(ch), new XVar(Constants.CURLOPT_FOLLOWLOCATION), new XVar(0));
    raw_data = XVar.Clone(CommonFunctions.curl_exec((XVar)(ch)));
    CommonFunctions.curl_close((XVar)(ch));
    xml = XVar.Clone(CommonFunctions.simplexml_load_string((XVar)(raw_data)));
    condition = XVar.Clone(xml.weather.current_conditions.condition["data"]);
    temp_c = XVar.Clone(xml.weather.current_conditions.temp_c["data"]);
    humidity = XVar.Clone(xml.weather.current_conditions.humidity["data"]);
    icon = XVar.Clone(xml.weather.current_conditions.icon["data"]);
    MVCFunctions.Echo("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" target="_blank" class="external" rel="nofollow">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>\">\r\n<html xmlns=\"<a href="http://www.w3.org/1999/xhtml" target="_blank" class="external" rel="nofollow">http://www.w3.org/1999/xhtml</a>\">\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\r\n<title>jQuery Weather</title>\r\n<link rel=\"stylesheet\" type=\"text/css\" href=\"css/reset.css\" />\r\n<link rel=\"stylesheet\" type=\"text/css\" href=\"css/style.css\" />\r\n");
    MVCFunctions.Echo("<s");
    MVCFunctions.Echo("cript src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js\" type=\"text/javascript\"></script>\r\n");
    MVCFunctions.Echo("<s");
    MVCFunctions.Echo("cript src=\"js/jquery.scrollTo-1.3.3.js\" type=\"text/javascript\"></script>\r\n");
    MVCFunctions.Echo("<s");
    MVCFunctions.Echo("cript src=\"js/jquery.localscroll-1.2.5.js\" type=\"text/javascript\" charset=\"utf-8\"></script>\r\n");
    MVCFunctions.Echo("<s");
    MVCFunctions.Echo("cript src=\"js/jquery.serialScroll-1.2.1.js\" type=\"text/javascript\" charset=\"utf-8\"></script>\r\n");
    MVCFunctions.Echo("<s");
    MVCFunctions.Echo("cript src=\"js/coda-slider.js\" type=\"text/javascript\" charset=\"utf-8\"></script>\r\n</head>\r\n\r\n<body>\r\n<div id=\"wrapper\" title=\"Herhangi bir gün seçebilirsiniz\">\r\n<div id=\"weatherBg\">\r\n<div class=\"scroll\">\r\n<div class=\"scrollContainer\">\r\n");
    i = new XVar(0);
    for(;i < MVCFunctions.count(xml.weather.forecast_conditions); i++)
    {
    data = XVar.Clone(xml.weather.forecast_conditions[i]);
    MVCFunctions.Echo("<div id=\"");
    MVCFunctions.Echo(data.day_of_week["data"]);
    MVCFunctions.Echo("\">\r\n<div class=\"todayWeather\">\r\n<div class=\"todayImage\"> <img src=\"\r\n");
    old = XVar.Clone(new XVar(0, "/ig/images/weather/"));
    var_new = XVar.Clone(new XVar(0, "images/weather/"));
    img = XVar.Clone(CommonFunctions.str_replace((XVar)(old), (XVar)(var_new), (XVar)(data.icon["data"])));
    old = XVar.Clone(new XVar(0, ".gif"));
    var_new = XVar.Clone(new XVar(0, ".png"));
    img = XVar.Clone(CommonFunctions.str_replace((XVar)(old), (XVar)(var_new), (XVar)(img)));
    MVCFunctions.Echo(img);
    MVCFunctions.Echo("\"\r\nalt=\"");
    MVCFunctions.Echo(data.condition["data"]);
    MVCFunctions.Echo("\" height=\"80\" width=\"120\" /></div>\r\n<div class=\"todayCondition\">\r\n<h1 class=\"city\"> ");
    MVCFunctions.Echo(placename);
    MVCFunctions.Echo("</h1>\r\n<h2 class=\"temp\"> ");
    MVCFunctions.Echo(data.low["data"]);
    MVCFunctions.Echo(" &deg;C | ");
    MVCFunctions.Echo(data.high["data"]);
    MVCFunctions.Echo(" &deg;C </h2>\r\n<h3 class=\"conditionData\"> ");
    MVCFunctions.Echo(data.condition["data"]);
    MVCFunctions.Echo("</h3>\r\n</div>\r\n</div>\r\n</div>\r\n");
    }
    MVCFunctions.Echo("</div>\r\n<!-- end scroll -->\r\n</div>\r\n<!-- end scrollContainer -->\r\n\r\n<div id=\"forecast\">\r\n\r\n");
    i = new XVar(0);
    for(;i < MVCFunctions.count(xml.weather.forecast_conditions); i++)
    {
    data = XVar.Clone(xml.weather.forecast_conditions[i]);
    MVCFunctions.Echo("<div class=\"weather\" >\r\n<div class=\"weatherDay\"> <a href=\"#");
    MVCFunctions.Echo(data.day_of_week["data"]);
    MVCFunctions.Echo("\"> ");
    MVCFunctions.Echo(data.day_of_week["data"]);
    MVCFunctions.Echo(" </a> </div>\r\n<div class=\"weatherImage\" > <img src=\"\r\n");
    old = XVar.Clone(new XVar(0, "/ig/images/weather/"));
    var_new = XVar.Clone(new XVar(0, "images/weather/"));
    img = XVar.Clone(CommonFunctions.str_replace((XVar)(old), (XVar)(var_new), (XVar)(data.icon["data"])));
    old = XVar.Clone(new XVar(0, ".gif"));
    var_new = XVar.Clone(new XVar(0, ".png"));
    img = XVar.Clone(CommonFunctions.str_replace((XVar)(old), (XVar)(var_new), (XVar)(img)));
    MVCFunctions.Echo(img);
    MVCFunctions.Echo("\" width=\"35\" height=\"25\" alt=\"");
    MVCFunctions.Echo(data.condition["data"]);
    MVCFunctions.Echo("\" /> </div>\r\n</div>\r\n");
    }
    MVCFunctions.Echo("\r\n</div> <!-- end forecast -->\r\n\r\n</div> <!-- end weatherBg -->\r\n\r\n</div> <!-- end wrapper-->\r\n</body>\r\n</html>");
    return MVCFunctions.GetBuferContentAndClearBufer();
    }
    catch(RunnerRedirectException ex)
    { return Redirect(ex.Message); }
    }
    }
    }

    Konu hakkında destek talebinde bulunabilirsiniz. www.bluedolphins.com.tr