Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: gh-pages
Fetching contributors…

Cannot retrieve contributors at this time

31 lines (29 sloc) 1.287 kb
<section name="php" class="php">
<p class="ioDesc">Request</p>
<pre class="incoming"><code class="language-php"><% headerFirst = true %><%= "<?php\n" %>
<% eos = "<<<EOT\n" %>
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "<%= @apiUrl %><%= @url %>");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
<% if @method is 'POST': %>
curl_setopt($ch, CURLOPT_POST, TRUE);
<% end %>
<% if @method is 'HEAD': %>
curl_setopt($ch, CURLOPT_NOBODY, TRUE);
<% end %>
<% if @method isnt 'GET' and @method isnt 'POST': %>
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "<%= @method %>");
<% end %>
<% if @method isnt 'GET' and (@contentType is "text/html" or @contentType is "text/plain"): %>
$fields = <%= eos %><%= @body or '' %>EOT;
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
<% else if @body and @body.length > 0: %>
curl_setopt($ch, CURLOPT_POSTFIELDS, <%= @helpers.escape @body %>);
<% end %>
<% if @headers and @helpers.isNotEmpty(@headers): %>curl_setopt($ch, CURLOPT_HTTPHEADER, array(<% for header, value of @headers: %><% if headerFirst: %><% headerFirst = false %><% else: %>, <% end %><%= @helpers.escape "#{header}: #{value}" %><% end %>));
<% end %>
$response = curl_exec($ch);
curl_close($ch);
var_dump($response);</code></pre>
</section>
Jump to Line
Something went wrong with that request. Please try again.