以下代码是发布远程表单。
<?php
$post_data['mail'] = 'parcel';
$post_data['destination'] = '1';
$post_data['weight'] = '300';
foreach ( $post_data as $key => $value)
{
$post_items[] = $key . '=' . $value;
}
$post_string = implode ('&', $post_items);
$curl_connection = curl_init('http://app1.hongkongpost.com/calc/eng/overseas/step2.php');
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);
$result = curl_exec($curl_connection);
//curl_close($curl_connection);
var_dump($reuslt);
print_r(curl_getinfo($curl_connection));
?>
结果是NULL,但是如果我评论该行 curl_setopt($ curl_connection,CURLOPT_RETURNTRANSFER,true);
页面返回将返回 http://app1.hongkongpost.com/calc/eng/overseas/step2.php 并显示结果(这意味着帖子成功),但我只想获得该表,而不是返回结果页面。有谁知道这是什么问题?
答案 0 :(得分:1)