2

我正在尝试在 ColdFusion 中重新创建一个 PHP 函数(因为我不了解 PHP),并且认为我的大部分函数都还不错,但是在处理 PHP 中的 cURL 函数时遇到了问题。

功能代码是

$cookie_string = $this->EASW_KEY."; ".$this->EASF_SESS ."; ".$this->PHISHKEY;
$ch = curl_init($search);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIE, $cookie_string);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'x-http-method-override: GET',
    $this->XSID)
);

//Contains the JSON file returned
$EAPSEARCH = curl_exec($ch);
curl_close($ch);

unset (List of variables);

我假设 CFHTTP 函数是我最好的盟友,但不确定如何处理重新编码。谁能指出我正确的方向?

4

1 回答 1

13

你是对的,CFHTTP 是要走的路。这是您上面转换为 CFHTTP 调用的调用版本:

<cfhttp url="http://some.server/path" method="POST" result="resultName>
  <cfhttpparam type="cookie" name="EASW_KEY" value="#EASW_VALUE#" />
  <cfhttpparam type="cookie" name="EASF_SESS" value="#EASF_SESS_VALUE#" />

  <cfhttpparam type="header" name="Content-Type" value="application/json" />
  <cfhttpparam type="header" name="x-http-method-override" value="GET" />

  <cfhttpparam type="body" value="#myJSONStringVariable#" />
</cfhttp>

<cfdump var="#resultName# />

cfhttp 标签记录在这里:http ://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_g-h_09.html

于 2013-01-18T13:11:07.083 回答