Bu PHP kodu ASP.NET eşdeğer?

2 Cevap php

Biz rss den dış verilere erişmek için sorgu dizesi? Url = "http://feedburner/whatever" ile proxy.php adında bir dosya çağrıları kullanır etki beslemeleri bir flaş geliştirici sahip değil swf koddan erişilebilir varsayılan. Örneğin ben tarayıcıda aşağıdaki olabilir: http://localhost/proxy.php?url=feedburner.com/a_feed ve tarayıcınızın adres çubuğuna doğrudan feedburner url koysaydı gibi tarayıcı sayfasını görüntülemek istiyorsunuz. Bu proxy.php dosyada PHP kodu aşağıda.

$header[] = "Content-type: text/xml";
$header[] = "Content-length: ".strlen($post_data);

$ch = curl_init( $_GET['url'] ); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);

if ( strlen($post_data)>0 ){
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
}

$response = curl_exec($ch);     

if (curl_errno($ch)) {
    print curl_error($ch);
} else {
    curl_close($ch);
    //$response=split("iso-8859-2",$response);
    //$response=join("UTF-8",$response);
    print $response;
}

Gayet iyi çalışıyor ama, çünkü hosting sınırlamalar biz asp.net de işlevselliği çoğaltmak gerekir. Ben PHP bilmiyorum ve kodu anlamak çabalarına rağmen ben sefil başarısız duyuyorum. Ben edebilmek için gereken ben asp.net ile ilk paragrafta ama Googling ve ben başarısız bir ashx dosya içinde XmlTextWriter ile bir tekniği çalışıyor rağmen açıklanan işlevselliği çoğaltmak. Ben burada ne eksik?

Ben dış etki kendisi gitmek kaynağını söyler ve bunu önlemek için istediğiniz gibi bir response.redirect işe yaramayacağını tahmin ediyorum.

Nasıl ASP.NET, bu PHP kodu işlevselliği ulaşmak istiyorsunuz?

2 Cevap

O yapıyor bütün sonra yanıt üzerine dışarı akışı dosyasını indirmek için (diğer şeyler arasında) bir HTTP istemcisi CURL yürütmesini. Sen HTTPWebRequest arayarak işlevselliği çoğaltabilirsiniz. Burada bir öğretici var:

http://support.microsoft.com/kb/303436

: Durumda kimse (tabii ki zor ... hey ama şu anda kodlanmıştır) aşağıda kod yazdı ve sadece hile yapar bu linke dayanarak bir kod pasajı, istiyorum

protected void Page_Load(object sender, EventArgs e)
{
    string URL = "http://feeds2.feedburner.com/the-foreigner";
    HttpWebRequest HttpWRequest = (HttpWebRequest)WebRequest.Create(URL);
    HttpWebResponse HttpWResponse = (HttpWebResponse)HttpWRequest.GetResponse();

    //Read the raw HTML from the request
    StreamReader sr = new StreamReader(HttpWResponse.GetResponseStream(), Encoding.ASCII);
    //Convert the stream to a string
    string s = sr.ReadToEnd();
    sr.Close();
    Response.Write(s); 
}