无法在Curl中将HTML作为变量发布

时间:2010-07-01 16:51:49

标签: php post arrays formatting curl

我使用CURL发布数组。如果不使用http_build_query(),它就无法工作。我在这个数组中设置了一行:

$postVars['key']='
<table style="border-style: solid;" width="850" align="center" bgcolor="#e9e9e9" border="3" bordercolor="#999999" cellpadding="0" cellspacing="0"> 
      <tbody><tr> 
           <td colspan="2" bgcolor="#d3d3d3" height="17">
';

然后做CURL:

$postURL = "https://post.xxx.org".$action;
$postData = http_build_query($postVars);
curl_setopt($ch, CURLOPT_URL, $postURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_FAILONERROR, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,0);

$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
echo $output;

然后事情就会破裂。当我取下分号时,一切都很好。为什么我需要逃离半冒号?!

1 个答案:

答案 0 :(得分:0)

您可以使用HTML entities