cURL,脚本返回503错误(服务不可用)

时间:2014-08-20 08:27:23

标签: php curl

我正在尝试登录页面' http://portal.demo.ascio.com/Logon.aspx'使用cURL但我收到此错误" 503服务不可用 没有服务器可用于处理此请求。 &#34 ;. 我正在发送正确的POST,我通过登录到普通页面从firebug获得。 我一直在寻找并发现可能我没有发送正确的标题。

代码是:

$url = 'http://portal.demo.ascio.com/Logon.aspx';

$login_string = 'THERE ARE MY POSTS WHICH CONTAINS PASSWORD...thats is definitelly right'
$headers = array();                                                                                                            
$headers[] = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
$headers[] = "Connection: Keep-Alive";                                         
$headers[] = "Host: portal.demo.ascio.com";                                    
$headers[] = "Referer: http://portal.demo.ascio.com/Logon.aspx";               
$headers[] = "Accept-Encoding: gzip, deflate";                                 
$headers[] = "Accept-Language: en-US,en;q=0.5";                                
$headers[] = "Content-type: application/x-www-form-urlencoded";                

//open connection                                                                                                              
$ch = curl_init();                                                                                                             

//set the url, number of POST vars, POST data                                  
curl_setopt($ch, CURLOPT_HEADER, true);                                        
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);                                
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);                                
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);                               
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);                               
curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);                               
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');                             
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');                            
curl_setopt($ch, CURLOPT_URL, $url);                                           
curl_setopt($ch, CURLOPT_POST, 5);                                              
curl_setopt($ch, CURLOPT_POSTFIELDS, $login_string);                             

$result = curl_exec($ch);                                                                                                      

print $result;                                                                                                                                                                                                                                     

curl_close($ch);

寻求帮助

1 个答案:

答案 0 :(得分:1)

一般情况下,如果你得到500系列的错误,例如503,这意味着你的请求发送到服务器端,输入中的某些内容导致服务器“中断”,可能是设计服务器本身。仔细检查您要发送的内容,也可以与服务API /规范进行比较。