You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

17 lines
1.4 KiB

<h1>PHP</h1>
<p>Below is an example of making an HTTP request to SITE_NAME from PHP.</p>
<div class="highlight"><pre><span></span><code><span class="nb">file_get_contents</span><span class="p">(</span><span class="s1">&#39;PING_URL&#39;</span><span class="p">);</span>
</code></pre></div>
<p>If you would like to setup timeout and retry options, as discussed in the
<a href="../reliability_tips/">reliability tips section</a>, there is a
<a href="https://www.phpcurlclass.com/">curl package</a> available that lets you do that easily:</p>
<div class="highlight"><pre><span></span><code><span class="k">use</span> <span class="nx">Curl\Curl</span><span class="p">;</span>
<span class="nv">$curl</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Curl</span><span class="p">();</span>
<span class="nv">$curl</span><span class="o">-&gt;</span><span class="na">setRetry</span><span class="p">(</span><span class="mi">20</span><span class="p">);</span>
<span class="nv">$curl</span><span class="o">-&gt;</span><span class="na">setTimeout</span><span class="p">(</span><span class="mi">5</span><span class="p">);</span>
<span class="nv">$curl</span><span class="o">-&gt;</span><span class="na">get</span><span class="p">(</span><span class="s1">&#39;PING_URL&#39;</span><span class="p">);</span>
</code></pre></div>
<p>Note: this code does not throw any exceptions.</p>