로컬 컴퓨터에서 클라이언트/서버 테스트 시나리오를 설정하고 있습니다. cURL을 통해 XML-RPC를 서버 PHP 스크립트로 보내려는 테스트 클라이언트 PHP 스크립트가 있습니다. . 서버 (var_dump($_POST)
사용) POST 어레이의 내용을 리턴함으로써 응답 할 때PHP/cURL - 서버가 POST 데이터를받지 못합니다.
$cnxn = curl_init();
$log = fopen("/var/www/mobile-client.localhost/www/curl.log", "w");
curl_setopt_array($cnxn,
array(
CURLOPT_FRESH_CONNECT => false,
CURLOPT_HEADER => false,
CURLOPT_HTTPHEADER => array(
"Content-Type: text/xml",
),
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => "m=boomshakalaka",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_STDERR => $log,
CURLOPT_URL => "http://mobile-server.localhost/rpc/index.php",
CURLOPT_VERBOSE => true,
)
);
$response = curl_exec($cnxn);
echo "<pre>";
var_dump(curl_errno($cnxn) . ':' . curl_error($cnxn), "<hr>", $response);
fclose($log);
curl_close($cnxn);
그러나, 응답은 비어있다.
나는 다음과 같은 내용했다 /var/www/mobile-client.localhost/www/curl.log
에서 생성 된 로그 파일의 내용 : 나는 또한
* About to connect() to mobile-server.localhost port 80 (#0)
* Trying 127.0.0.1... * connected
* Connected to mobile-server.localhost (127.0.0.1) port 80 (#0)
> POST /rpc/index.php HTTP/1.1
Host: mobile-server.localhost
Accept: */*
Content-Type: text/xml
Content-Length: 15
< HTTP/1.1 200 OK
< Date: Tue, 25 Jan 2011 04:57:15 GMT
< Server: Apache/2.2.14 (Ubuntu)
< X-Powered-By: PHP/5.3.2-1ubuntu4.7
< Vary: Accept-Encoding
< Content-Length: 1337
< Content-Type: text/html
<
* Connection #0 to host mobile-server.localhost left intact
* Closing connection #0
와이어 샤크 내 루프백 주소를 모니터링하고 캡처 로그에 다음 볼 수 있습니다 :
POST /rpc/index.php HTTP/1.1
Host: mobile-server.localhost
Accept: */*
Content-Type: text/xml
Content-Length: 15
m=boomshakalaka
내 POST 데이터가 사라지는 위치는 어디입니까? 실제 서버 응답에 관심있는 사람들을 위해
-의 index.php의 내용은 다음과 같습니다 ----/*
CURLOPT_HTTPHEADER => array(
"Content-Type: text/xml",
),
*/
편집 :
<?php
var_dump(":)");
var_dump("POST: ", $_POST);
var_dump("GET: ", $_GET);
var_dump("SERVER: ", $_SERVER);
'콘텐츠 길이로 이동합니다 1337'을 ... 재미있는. 'var_dump ($ response)'는 무엇을 제공합니까? –
이 게시물을 편집하여 서버 스크립트를 표시했습니다. – HorusKol