2010-03-16 4 views
2

좋아, SSL 사이트에 cURL을 사용하여 HTTP_POST를 만들고 싶습니다. 이미 서버에 인증서를 가져 왔습니다. 그것은 "500"반환 계속cURL + HTTP_POST, 계속 500 오류가 발생합니다. 모르겠어?

$url = "https://www.xxx.xxx"; 
$post = "";# all data that going to send 

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_POST, true); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $post); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); 
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0'); 

$exe = curl_exec($ch); 
$getInfo = curl_getinfo($ch); 

if ($exe === false) { 
    $output = "Error in sending"; 
    if (curl_error($ch)){ 
     $output .= "\n". curl_error($ch); 
    } 
} else if($getInfo['http_code'] != 777){ 
    $output = "No data returned. Error: " . $getInfo['http_code']; 
    if (curl_error($ch)){ 
     $output .= "\n". curl_error($ch); 
    } 
} 

curl_close($ch); 

echo $output; 

: 이것은 내 코드입니다. w3schools를 기준으로 500은 내부 서버 오류를 의미합니다. 내 서버에 문제가 있습니까? 이 문제를 어떻게 해결할 것인가?

답변

0

서버 또는 서버에서 실행되는 스크립트에 문제가있어 어쩌면 처리되지 않은 예외가 발생할 수 있습니다.

서버의 액세스 및 오류 로그를 확인해야합니다.

+0

내 호스팅 회사에 문의해야합니까? – mysqllearner

+0

서버의 로그에 직접 액세스 할 수없는 경우 예를 들어 보낼 수 있습니다. – Kaltezar

1
$url = "https://www.xxx.xxx"; 
$post = "";# all data that going to send 

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_POST, true); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $post); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); 
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0'); 

$exe = curl_exec($ch); 
$getInfo = curl_getinfo($ch); 

if ($exe === false) { 
$output = "Error in sending"; 
if (curl_error($ch)){ 
    $output .= "\n". curl_error($ch); 
} 
} else if($geInfo['http_code'] != 777){  //here $geInfo should be $getInfo 
$output = "No data returned. Error: " . $geInfo['http_code'];//as preline 
if (curl_error($ch)){ 
    $output .= "\n". curl_error($ch); 
} 
} 

curl_close($c); //$c should be $ch 

echo $output; 

BTW : CURL의 moduel가 설치되어 있는지 확인합니다.

+0

죄송합니다. 일부 오타가 잘못되었습니다. 나는 코드를 편집하고 있었다. 내가 코드를 확인, 변수 이름이 정확합니다, 그것은 여전히 ​​"오류 : 500"을 제공합니다. 어떤 생각? (나는 내 ​​질문을 피하고, 혼란스럽지 않고, 고마워한다.) – mysqllearner

+0

나는 내 wamp에서 그것을 테스트했다. 단지 잘 작동한다 .200이있다. – Young

+0

그러면 서버 문제 일 수 있습니까? 그 500의 의미는 무엇입니까? 나는 아직도 통과 할 수 없다, 돌아 오는 길을 유지해라 500. Argggghhh !!!! – mysqllearner

6

일부 서버 (특히 SSL로 요청)는 요청 매개 변수 일부가 잘못 설정된 경우 500을 반환합니다.

curl_setopt(CURLOPT_REFERER, 'http://site.com/ref_page');

  • 로, 헤더 필요한 경우 : 적절한 "리퍼러"로 설정

    • :

      을 방지하기 위해«500 오류»(예를 들어)을해야합니다 올바른 "User-Agent :"헤더를 설정하고

    curl_setopt(CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)');

관련 문제