2012-09-30 3 views
0

내 도메인의 URL에 게시 된 데이터를 수신하고, 특정 필드 값을 확인하고, 필요한 경우 데이터베이스를 업데이트 한 다음 수신 한 데이터를 다른 URL에 게시합니다.PHP가 데이터를 다시 게시 함

불행히도 내가 게시하고있는 URL (https)에는 테스트 베드가 없거나 그런 것이 없으므로 내가 재 게시 한 내용이 수신되었는지 확인할 필요가 있습니다.

합리적인 방법 인 것처럼 보입니까?

감사

foreach($_POST as $key=>$value) 
{ 
    $fields_string .= $key.'='.$value.'&'; 
} 
$fields_string = substr_replace($fields_string, "", -1); 

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"); 
curl_setopt($ch, CURLOPT_URL, "https://anotherdomain.com/script.php"); 
curl_setopt($ch, CURLOPT_ENCODING, ""); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($ch, CURLOPT_AUTOREFERER, true); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); 
curl_setopt($ch, CURLOPT_TIMEOUT, 30); 
curl_setopt($ch, CURLOPT_MAXREDIRS, 10); 
curl_setopt($ch, CURLOPT_POST, 1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); 
$result = curl_exec($ch); 
$response = curl_getinfo($ch);  
curl_close($ch);  

$fh = fopen('audit.log', 'a'); 
fwrite($fh, $response."\r\n"); 
fclose($fh); 

답변

1

CURLOPT_POSTFIELDS 직접

이 잘 작동 할 array을 수행 할 수 있습니다

curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST); 

는 또한 경우에 여러 시도를 관리하는 데 필요한 서버가 다운 ... ..