2011-11-16 3 views
0

서버의 스크립트에 데이터를 게시해야합니다. curl을 사용하고 자세한 오류보고를 사용하고 있습니다. 아무도 왜 이것이 작동하지 않는지 알 수 있습니까?문제 해결 방법 - CURL 스크립트로 데이터 게시

surname=smth&address1=No+Value&this=that 
:

<?php log_error("success",ERROR_LOG_TO_STDERR); ?> 

내 포스트는 다음과 같이 문자열을 바르 :

감사합니다,

게시 스크립트

function makePost($postvars, $count) { 

$url = 'http://servername.something.org/php/callback-f.php'; 

$ch = curl_init(); 

curl_setopt ($ch, CURLOPT_POST, true); 
curl_setopt($ch,CURLOPT_URL,$url); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); 
curl_setopt($ch,CURLOPT_POSTFIELDS,$postvars); 
curl_setopt($ch, CURLOPT_VERBOSE, 1); 

$result = curl_exec($ch); 
curl_close($ch); 
} 

에 게시 된 스크립트는이 줄을 포함

내가 돌아올 결과는 이것이다 :

Connected to myserver.org port 80 
> POST /php/callback-f.php HTTP/1.1 
Host: myserver.org 
Pragma: no-cache 
Accept: */* 
Content-Length: 1510 
Content-Type: application/x-www-form-urlencoded 

< HTTP/1.1 301 Moved Permanently 
< Location: https://myserver/php/callback-f.php 
< Content-Length: 0 
< Date: Wed, 16 Nov 2011 16:21:23 GMT 
< Server: lighttpd/1.4.28 
* Connection #0 to host left intact 
* Closing connection #0 
+1

테스트 스크립트가 https를 통해서만 액세스 할 수 있지만 http를 통해 게시하는 것 같습니다. – liquorvicar

답변

1

것은 사용을 시도 할 수 :

 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
+0

안녕하세요, 빠른 답변 주셔서 감사합니다. 불행히도 그것은 작동하지 않습니다. – rix

+0

hmmm 문제는 다음과 같습니다. SSL : 인증서 주체 이름 '일반 이름 (예 : YOUR 이름)'이 (가) 대상 호스트 이름 'myservername.org'과 일치하지 않습니다. – rix

+0

51 curl_setopt ($ ch, CURLOPT_POST, true); 52 curl_setopt ($ ch, CURLOPT_URL, $ url); 53 curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1); 54 curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ postvars); 55 curl_setopt ($ ch, CURLOPT_VERBOSE, 1); 56 curl_setopt ($ ch, CURLOPT_FOLLOWLOCATION, 1); 57 curl_setopt ($ ch, CURLOPT_SSL_VERIFYPEER, 0); 58 curl_setopt ($ ch, CURLOPT_SSL_VERIFYHOST, 0); 좋습니다. 301 리디렉션 문제가 있습니다. 도움을 제공해 주셔서 감사합니다. 남아있는 모든 것은 다음과 같습니다. * RFC 2616/10.3.2를 위반하고 POST에서 GET으로 전환 컬링 스위치가 리디렉션 할 때 가져옵니다. 이 일을 막기 위해 어쨌든 가나 요? – rix

1

당신은 301 오류를 다시 얻고있다. 귀하의 시도한 URL은 http://servername.something.org이고 301은 페이지가 https://myserver (https 프로토콜 참조)에 있습니다.

301 오류는 사용자 동의없이 POST에서 리디렉션되지 않아야합니다.