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

httprequest ile xml post

elimde xml api için bir adres, ve bir de xml formatı var.
ben bunu curl ile yaptım, ama "Runtime Error" verdi.

httprequest ile yapmak istiyorum. aşağıdaki örnek kodu buldum.

ancak bu HttpRequest class ı nedir bulamadım.
buldugum classlar hep bir taraftan sorun verdi.

php.ini de bi ayar yap denmiş bir yerde, server benim olmadıgı için bunu da yapamıyorum.

yardım ederseniz çok sevinirim

$req =& new HttpRequest($url);
$req->addHeader("Content-Type", "text/xml");
$req->addHeader("Content-Length", strlen($XML));
$req->setMethod(HTTP_REQUEST_METHOD_POST);
$req->addRawPostData($XML, true);
$req->sendRequest();
echo $req->getResponseBody();  
+0
-0
Cevaba KatılıyorumKatılmıyorum
Cevap Yaz Yorum Yaz Arşivime Ekle Takip Et

Cevaplar

  • protest adlı üyenin fotoğrafı
    11 yıl önce yazılmış
    32 cevap - 6 soru
        $ch = curl_init(); 		                      	    // Initialize curl handle 
        curl_setopt($ch, CURLOPT_URL, $url); 	      	    // Set the url
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);		    // Return as a variable 
        curl_setopt($ch, CURLOPT_POST, 1); 	              // Set POST method 
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: text/xml'));
        curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);   // Set the POST variables
        $response = curl_exec($ch); 			                // Run the whole process and return the response
        curl_close($ch); 				                          // Close the curl handle
    

    şeklinde çözüldü.