<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>CURL context option listing</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="context.ssl.html">SSL context options</a></div> <div class="next" style="text-align: right; float: right;"><a href="context.phar.html">Phar context options</a></div> <div class="up"><a href="context.html">Context options and parameters</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="context.curl" class="refentry"> <div class="refnamediv"> <h1 class="refname">CURL context options</h1> <p class="refpurpose"><span class="refname">CURL context options</span> — <span class="dc-title">CURL context option listing</span></p> </div> <div class="refsect1 description" id="refsect1-context.curl-description"> <h3 class="title">Description</h3> <p class="para"> CURL context options are available when the <a href="intro.curl.html" class="link">CURL</a> extension was compiled using the <strong class="option unknown">--with-curlwrappers</strong> configure option. </p> </div> <div class="refsect1 options" id="refsect1-context.curl-options"> <h3 class="title">Options</h3> <p class="para"> <dl> <dt id="context.curl.method"> <span class="term"> <em><code class="parameter">method</code></em> <span class="type"><a href="language.types.string.html" class="type string">string</a></span> </span> <dd> <p class="para"> <strong><code>GET</code></strong>, <strong><code>POST</code></strong>, or any other HTTP method supported by the remote server. </p> <p class="para"> Defaults to <strong><code>GET</code></strong>. </p> </dd> </dt> <dt id="context.curl.header"> <span class="term"> <em><code class="parameter">header</code></em> <span class="type"><a href="language.types.string.html" class="type string">string</a></span> </span> <dd> <p class="para"> Additional headers to be sent during request. Values in this option will override other values (such as <em>User-agent:</em>, <em>Host:</em>, and <em>Authentication:</em>). </p> </dd> </dt> <dt id="context.curl.user-agent"> <span class="term"> <em><code class="parameter">user_agent</code></em> <span class="type"><a href="language.types.string.html" class="type string">string</a></span> </span> <dd> <p class="para"> Value to send with User-Agent: header. </p> <p class="para"> By default the <a href="filesystem.configuration.html#ini.user-agent" class="link">user_agent</a> <var class="filename">php.ini</var> setting is used. </p> </dd> </dt> <dt id="context.curl.content"> <span class="term"> <em><code class="parameter">content</code></em> <span class="type"><a href="language.types.string.html" class="type string">string</a></span> </span> <dd> <p class="para"> Additional data to be sent after the headers. This option is not used for <strong><code>GET</code></strong> or <strong><code>HEAD</code></strong> requests. </p> </dd> </dt> <dt id="context.curl.proxy"> <span class="term"> <em><code class="parameter">proxy</code></em> <span class="type"><a href="language.types.string.html" class="type string">string</a></span> </span> <dd> <p class="para"> URI specifying address of proxy server. (e.g. <em>tcp://proxy.example.com:5100</em>). </p> </dd> </dt> <dt id="context.curl.max-redirects"> <span class="term"> <em><code class="parameter">max_redirects</code></em> <span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span> </span> <dd> <p class="para"> The max number of redirects to follow. Value <em>1</em> or less means that no redirects are followed. </p> <p class="para"> Defaults to <em>20</em>. </p> </dd> </dt> <dt id="context.curl.curl-verify-ssl-host"> <span class="term"> <em><code class="parameter">curl_verify_ssl_host</code></em> <span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span> </span> <dd> <p class="para"> Verify the host. </p> <p class="para"> Defaults to <strong><code>FALSE</code></strong> </p> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> This option is available for both the http and ftp protocol wrappers. </p> </p></blockquote> </dd> </dt> <dt id="context.curl.curl-verify-ssl-peer"> <span class="term"> <em><code class="parameter">curl_verify_ssl_peer</code></em> <span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span> </span> <dd> <p class="para"> Require verification of SSL certificate used. </p> <p class="para"> Defaults to <strong><code>FALSE</code></strong> </p> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> This option is available for both the http and ftp protocol wrappers. </p> </p></blockquote> </dd> </dt> </dl> </p> </div> <div class="refsect1 examples" id="refsect1-context.curl-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="context.curl.example-post"> <p><strong>Example #1 Fetch a page and send POST data</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /><br />$postdata </span><span style="color: #007700">= </span><span style="color: #0000BB">http_build_query</span><span style="color: #007700">(<br /> array(<br /> </span><span style="color: #DD0000">'var1' </span><span style="color: #007700">=> </span><span style="color: #DD0000">'some content'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">'var2' </span><span style="color: #007700">=> </span><span style="color: #DD0000">'doh'<br /> </span><span style="color: #007700">)<br />);<br /><br /></span><span style="color: #0000BB">$opts </span><span style="color: #007700">= array(</span><span style="color: #DD0000">'http' </span><span style="color: #007700">=><br /> array(<br /> </span><span style="color: #DD0000">'method' </span><span style="color: #007700">=> </span><span style="color: #DD0000">'POST'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">'header' </span><span style="color: #007700">=> </span><span style="color: #DD0000">'Content-type: application/x-www-form-urlencoded'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">'content' </span><span style="color: #007700">=> </span><span style="color: #0000BB">$postdata<br /> </span><span style="color: #007700">)<br />);<br /><br /></span><span style="color: #0000BB">$context </span><span style="color: #007700">= </span><span style="color: #0000BB">stream_context_create</span><span style="color: #007700">(</span><span style="color: #0000BB">$opts</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$result </span><span style="color: #007700">= </span><span style="color: #0000BB">file_get_contents</span><span style="color: #007700">(</span><span style="color: #DD0000">'http://example.com/submit.php'</span><span style="color: #007700">, </span><span style="color: #0000BB">false</span><span style="color: #007700">, </span><span style="color: #0000BB">$context</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div> <div class="refsect1 seealso" id="refsect1-context.curl-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><a href="context.socket.html" class="xref">Socket context options</a></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="context.ssl.html">SSL context options</a></div> <div class="next" style="text-align: right; float: right;"><a href="context.phar.html">Phar context options</a></div> <div class="up"><a href="context.html">Context options and parameters</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>