0
프록시 목록을 사용하여 URL에 게시하는 스크립트를 만들려고합니다. 스크립트는 프록시 (CURLOPT_PROXY를 null로 설정)를 설정하지 않아도 제대로 작동하는 것으로 보이지만 프록시를 설정하면 작동하지 않는 것 같습니다. 아무도 내가 여기서 뭘 잘못하고 있는지 알아?PHP CURL이 POST에 프록시 사용
ERROR
The requested URL could not be retrieved
Invalid Request error was encountered while trying to process the request:
POST /###/ HTTP/1.1
Host: ###
Accept: */*
Proxy-Connection: Keep-Alive
Content-Length: 368
Expect: 100-continue
Content-Type: multipart/form-data; boundary=----------------------------9b24e849cac0
Some possible problems are:
Missing or unknown request method.
Missing URL.
Missing HTTP Identifier (HTTP/1.0).
Request is too large.
Content-Length missing for POST or PUT requests.
Illegal character in hostname; underscores are not allowed.
그리고 내 코드는 다음과 같습니다 : 프록시와 함께 게시 할 때 내가 갖는 오류는
$url = 'urltopost';
$proxy = 'proxy:port';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_POST, true);
$data = array(
'postname1' => 'value1',
'postname2' => 'value2'
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$curl_scraped_page = curl_exec($ch);
curl_close($ch);
echo $curl_scraped_page;
꽤 이상한 프록시 : 포트 표기법은 POST 변수를 추가하지 않았을 때 어떻게 작동 했습니까? 그러나 빠른 응답을 주셔서 감사합니다! – user2069116
이 솔루션에 동의하지는 않지만 왜 다른 방식으로 작동하지 않는지 설명해주십시오. 나는 어디에서나 찾을 수 없다 ... 그리고 모든 예제 (curl_setopt()에 대한 PHP 매뉴얼과 함께) 포트와 호스트를 함께 넣어 ... 고마워! – Jull
내가 잘못 본 것이 아니라면 지구 환경도 충분할 것입니까? –