What would this code look like in ColdFusion?
protected function httpPut($url, $params = null, $data = null)
{
$fh = fopen('php://memory', 'rw');
fwrite($fh, $data);
rewind($fh);
$ch = curl_init($url);
$this->addOAuthHeaders($ch, $url, $params['oauth']);
curl_setopt($ch, CURLOPT_PUT, 1);
curl_setopt($ch, CURLOPT_INFILE, $fh);
curl_setopt($ch, CURLOPT_INFILESIZE, strlen($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$resp = $this->curl->addCurl($ch);
fclose($fh);
return $resp;
}
I have something like the following, but it doesn't seem to be working.
<cffile action="write" file="d:\my\directory\path\test.xml" output="#arguments.requestXML#">
<cfhttp url="#oaAccessTokenURL#" method="#arguments.requestType#" charset="UTF-8">
<cfheader name="Authorization" value="#oauthheader#">
<cfhttpparam type="file" name="Course" file="d:\my\directory\path\test.xml">
</cfhttp>
I don't know enough about PHP to understand how the $data variable (which is just a string of XML data) is getting put into the http request and how to duplicate that in ColdFusion.
I would try adding method="put" to your cfhttp call. That will make CFHTTP send the correct http verb (PUT in this case).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With