日期:2014-05-16  浏览次数:20482 次

curl post错误,求解
$url="http://dct.dhl.com/input.jsp?langId=cn&originCCId=CN";
$post_data="orgCtry=CHINA, PEOPLES REPUBLIC (CN)&orgZip=510011&orgCity=GUANGZHOU&dstCtry=HONG KONG (HK)&dstCity=HONG KONG&declValCur=USD&weight=0.2&shipping_options=Submit";
$ch=curl_init();
echo phpinfo();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch,CURLOPT_HEADER,0);
curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3'); 
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$post_data);
//ob_start();
$output=curl_exec($ch);
curl_close($ch);
print_r($output);
//ob_end_flush();

不知道为什么post不成功啊,求救

------解决方案--------------------
// 检查是否有错误发生
if(curl_errno($ch))
{
    echo 'Curl error: ' . curl_error($ch);
}
------解决方案--------------------
$url="http://dct.dhl.com/input.jsp?langId=cn&originCCId=CN";
print_r(get_headers($url));
Array
(
    [0] => HTTP/1.1 200 OK
    [1] => Date: Sat, 11 Jan 2014 02:44:34 GMT
    [2] => Content-Length: 10641
    [3] => Content-Type: text/html; charset=UTF-8
    [4] => X-Powered-By: Servlet/2.5 JSP/2.1
    [5] => Set-Cookie: JSESSIONID=pmT2SQwS3QSTgbTCNygyJlPjvC3hKmkgHDyJYQys145vGnvmBpbP!1824887213; path=/; HttpOnly
    [6] => Set-Cookie: BIGipServerdct_ratio=627591333.43295.0000; path=/
    [7] => Via: 1.0 dct.dhl.com
    [8] => Connection: close
    [9] => Set-Cookie: TSe13065=c415deb6fcd5ecb861ff24a0e0fc22856d2ecfd394ca9e6352d0b01160ac0ec57b9c5c10beb8cf9b0458f95b; Path=/
)
该站使用了 session 和 stoke 而你却没有
自然就模拟失败了
------解决方案--------------------
引用:
Quote: 引用:

$url="http://dct.dhl.com/input.jsp?langId=cn&originCCId=CN";
print_r(get_headers($url));
Array
(
    [0] => HTTP/1.1 200 OK
    [1] => Date: