Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Translate PHP PUT HTTP request to ColdFusion

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.

like image 958
Jason Avatar asked Nov 14 '22 08:11

Jason


1 Answers

I would try adding method="put" to your cfhttp call. That will make CFHTTP send the correct http verb (PUT in this case).

like image 75
Terry Ryan Avatar answered Dec 09 '22 13:12

Terry Ryan