【问题标题】:Trouble posting HTML as variable in Curl无法在 Curl 中将 HTML 作为变量发布
【发布时间】:2010-07-01 16:51:48
【问题描述】:

我正在使用 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;

然后事情就破裂了。当我删除分号时,一切都很好。为什么我需要转义分号?!

【问题讨论】:

  • 我不明白这个问题 - 你在哪里删除了分号?
  • 可能应该记下:我从“border-style:solid;”中删除了它

标签: php post arrays formatting curl


【解决方案1】:

你可以使用HTML entities

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-07
    • 1970-01-01
    • 2022-06-17
    • 1970-01-01
    • 2011-01-16
    • 1970-01-01
    相关资源
    最近更新 更多