PHP: Başlıklarla Post verileri çalışmıyor ...

4 Cevap php

Basit Komut

<?php
$host = "mysite.com";
$path = "/test.php";
$data = "drivingMeCrazy";
$data = urlencode($data);

header("POST $path HTTP/1.1\r\n" );
header("Host: $host\r\n" );
header("Content-type: application/x-www-form-urlencoded; charset=utf-8\r\n" );
header("Content-length: " . strlen($data) . "\r\n" );
header("Connection: close\r\n\r\n" );
header($data);
?>

Bu çalıştırırken, benim sunucu bana İç Hatası veriyor. Yapmam gereken sadece .... POST. Başka bir şey. Ben bir yanıt ya da bir şey gerekmez.

Buradan aşağıdaki Özellikleri: http://www.sixapart.com/pronet/docs/trackback_spec.

4 Cevap

Ben burada arıyordu bir cevap buldu:

http://bytes.com/topic/php/answers/1211-doing-http-post

Çalışmış olurdu kıvrılma. Ben sadece yanı sıra farklı bir platformda bu işi yapmak istedim, bu yüzden en doğru yolu bulmak istiyordu. Tekrar teşekkürler.

header function is for setting the header for the response. If you want to make a request to another server, try cURL.

Böyle bir şey arıyorsanız:

$process = curl_init($host);                                                                         
curl_setopt($process, CURLOPT_HTTPHEADER, array('Content-Type: application/xml', $additionalHeaders));  //<-- update to reflect your content-type
curl_setopt($process, CURLOPT_HEADER, 1);                                                                           
curl_setopt($process, CURLOPT_USERPWD, $username . ":" . $password); // <-- you probably don't need that                                                
curl_setopt($process, CURLOPT_TIMEOUT, 30);                                                                         
curl_setopt($process, CURLOPT_POST, 1);                                                                             
curl_setopt($process, CURLOPT_POSTFIELDS, $payloadName);                                                            
curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE);                                                                
$return = curl_exec($process);  

Sen header(), bir 3. parti sunucuya veri göndermek için kullanamazsınız. header() sadece başlık bilgilerini web sunucunuza istekte istemciye gönderir.

Sunucu tarafı PHP 3. şahıslara isteklerini başlatılması için cURL kütüphanesine içine bak:

http://ca.php.net/manual/en/book.curl.php

Ben bu kütüphane için kefil olamaz, ama PHP için Trackbacks bir serbestçe kullanılabilir uygulama gibi görünüyor:

http://sourceforge.net/projects/phptrackback/