-1

下面的代码是发布一个远程表单。

<?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 并显示结果(表示发帖成功),但我只想获取该表,不返回结果页面。有谁知道是什么问题?

4

1 回答 1

1
  1. 不正确的变量名 $reuslt。替换:“var_dump($reuslt);” 到“var_dump($result);”
  2. 添加 curl_setopt($curl_connection, CURLOPT_POST, 1);
于 2013-02-07T09:43:37.067 回答