Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat request does the PHP cURL function produce?
    text
    copied!<p>I am currently writing an C# windows service, which integrates with a PHP page. I have an example of code making the request in PHP which is below however I have never developed in PHP and don't understand how the cURL function performs the request. </p> <p>Is there anyway to retrieve the request which is being sent? Or can anyone provide an example of how the request would look and how the request is sent so I can replicate the request in C#.</p> <p>Thank you for any help.</p> <pre><code>public function api(/* polymorphic */) { $args = func_get_args(); if (is_array($args[0])) { $serviceId = $this-&gt;getApiServiceId($args[0]["method"]); unset($args[0]["method"]); $args[0]["serviceId"] = $serviceId; $args[0]["dealerId"] = $this-&gt;dealerId; $args[0]["username"] = $this-&gt;username; $args[0]["password"] = $this-&gt;password; $args[0]["baseDomain"] = $this-&gt;baseDomain; return json_decode($this-&gt;makeRequest($args[0])); } else { throw Exception("API call failed. Improper call."); } } protected function makeRequest($params, $ch=null) { if (!$ch) { $ch = curl_init(); } $opts = self::$CURL_OPTS; if ($this-&gt;useFileUploadSupport()) { $opts[CURLOPT_POSTFIELDS] = $params; } else { $opts[CURLOPT_POSTFIELDS] = http_build_query($params, null, '&amp;'); } // disable the 'Expect: 100-continue' behaviour. This causes CURL to wait // for 2 seconds if the server does not support this header. if (isset($opts[CURLOPT_HTTPHEADER])) { $existing_headers = $opts[CURLOPT_HTTPHEADER]; $existing_headers[] = 'Expect:'; $opts[CURLOPT_HTTPHEADER] = $existing_headers; } else { $opts[CURLOPT_HTTPHEADER] = array('Expect:'); } curl_setopt_array($ch, $opts); $result = curl_exec($ch); if ($result === false) { $e = new WPSApiException(array( 'error_code' =&gt; curl_errno($ch), 'error' =&gt; array( 'message' =&gt; curl_error($ch), 'type' =&gt; 'CurlException', ), )); curl_close($ch); throw $e; } curl_close($ch); return $result; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload