2014-09-11 2 views
1

POST 또는 GET 요청이 도착하고 이에 대한 코드가 작동합니다. 그런 다음 첫 번째 (헤더, 본문/내용)의 복제본을 새로 작성하여 수신 된 그대로 다른 서버로 보내야합니다. PHP에서이 작업을 수행하는 가장 빠른 방법은 무엇입니까?요청을 복사하여 다른 서버로 전송

+0

http://benalman.com/code/projects/php-simple-proxy/docs/files/ba-simple-proxy-php.html 해당 라이브러리 –

+0

에 볼을 시도 할 수 있습니다 당신은 시도 할 수 있습니다 : http://php.net/manual/en/intro.curl.php –

답변

1

이와 비슷한?

$data = $_REQUEST; 

/* 
* cURL request 
* 
* @param $url  string The url to post to 'theurlyouneedtosendto.com/m/admin'/something' 
* @param $req  string Request type. Ex. 'POST', 'GET' or 'PUT' 
* @param $data  array  Array of data to be POSTed 
* @return $result Obj  HTTP resonse in json decoded object 
*/ 
function curl_req($url, $req, $data='') 
    { 
     $ch = curl_init($url); 
     curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $req); 
     if (is_array($data)) { 
      curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); 
     } 
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
     $result = curl_exec($ch); 
     $result = json_decode($result); 
     curl_close($ch); 
     return $result; 
    } 


    $result = curl_req("theurlyouneedtosendto.com/path/after/url", "POST", $data); 
+0

본문/내용은 어떻습니까? –

+0

이런 와우, curl_setopt()에 대한 수백 가지 옵션이 있습니다! –

관련 문제