<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.oauth.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'oauth.fetch.php',
    1 => 'OAuth::fetch',
    2 => 'Fetch an OAuth protected resource',
  ),
  'up' => 
  array (
    0 => 'class.oauth.php',
    1 => 'OAuth',
  ),
  'prev' => 
  array (
    0 => 'oauth.enablesslchecks.php',
    1 => 'OAuth::enableSSLChecks',
  ),
  'next' => 
  array (
    0 => 'oauth.generatesignature.php',
    1 => 'OAuth::generateSignature',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/oauth/oauth/fetch.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="oauth.fetch" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">OAuth::fetch</h1>
  <p class="verinfo">(PECL OAuth &gt;= 0.99.1)</p><p class="refpurpose"><span class="refname">OAuth::fetch</span> &mdash; <span class="dc-title">Fetch an OAuth protected resource</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-oauth.fetch-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>OAuth::fetch</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$protected_resource_url</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter">$extra_parameters</code><span class="initializer"> = ?</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$http_method</code><span class="initializer"> = ?</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter">$http_headers</code><span class="initializer"> = ?</span></span><br>): <span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span></div>

  <p class="simpara">
   Fetch a resource.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-oauth.fetch-parameters">
  <h3 class="title">Parameters</h3>
  <dl>
   
    <dt><code class="parameter">protected_resource_url</code></dt>
    <dd>
     <span class="simpara">
      URL to the OAuth protected resource.
     </span>
    </dd>
   
   
    <dt><code class="parameter">extra_parameters</code></dt>
    <dd>
     <span class="simpara">
      Extra parameters to send with the request for the resource.
     </span>
    </dd>
   
   
    <dt><code class="parameter">http_method</code></dt>
    <dd>
     <span class="simpara">
      One of the <strong><code><a href="oauth.constants.php#constant.oauth-http-method-get">OAUTH_HTTP_METHOD_<span class="replaceable">*</span></a></code></strong>
      OAUTH constants, which includes
      GET, POST, PUT, HEAD, or DELETE.
     </span>
     <span class="simpara">
      HEAD (<strong><code><a href="oauth.constants.php#constant.oauth-http-method-head">OAUTH_HTTP_METHOD_HEAD</a></code></strong>) can be useful for
      discovering information prior to the request (if OAuth credentials are
      in the <code class="literal">Authorization</code> header).
     </span>
    </dd>
   
   
    <dt><code class="parameter">http_headers</code></dt>
    <dd>
     <span class="simpara">
      HTTP client headers (such as User-Agent, Accept, etc.)
     </span>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-oauth.fetch-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="simpara">
   Returns <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> on success or <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> on failure.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-oauth.fetch-changelog">
  <h3 class="title">Changelog</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Description</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>PECL oauth 1.0.0</td>
      <td>
       Previously returned <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> on failure, instead of <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
      </td>
     </tr>

     <tr>
      <td>PECL oauth 0.99.5</td>
      <td>
       The <code class="parameter">http_method</code> parameter was added
      </td>
     </tr>

     <tr>
      <td>PECL oauth 0.99.8</td>
      <td>
       The <code class="parameter">http_headers</code> parameter was added
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-oauth.fetch-examples">
  <h3 class="title">Examples</h3>
  <div class="example" id="example-1">
   <p><strong>Example #1 <span class="function"><strong>OAuth::fetch()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">try {<br />    </span><span style="color: #0000BB">$oauth </span><span style="color: #007700">= new </span><span style="color: #0000BB">OAuth</span><span style="color: #007700">(</span><span style="color: #DD0000">"consumer_key"</span><span style="color: #007700">,</span><span style="color: #DD0000">"consumer_secret"</span><span style="color: #007700">,</span><span style="color: #0000BB">OAUTH_SIG_METHOD_HMACSHA1</span><span style="color: #007700">,</span><span style="color: #0000BB">OAUTH_AUTH_TYPE_AUTHORIZATION</span><span style="color: #007700">);<br />    </span><span style="color: #0000BB">$oauth</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setToken</span><span style="color: #007700">(</span><span style="color: #DD0000">"access_token"</span><span style="color: #007700">,</span><span style="color: #DD0000">"access_token_secret"</span><span style="color: #007700">);<br /><br />    </span><span style="color: #0000BB">$oauth</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">fetch</span><span style="color: #007700">(</span><span style="color: #DD0000">"http://photos.example.net/photo?file=vacation.jpg"</span><span style="color: #007700">);<br /><br />    </span><span style="color: #0000BB">$response_info </span><span style="color: #007700">= </span><span style="color: #0000BB">$oauth</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getLastResponseInfo</span><span style="color: #007700">();<br />    </span><span style="color: #0000BB">header</span><span style="color: #007700">(</span><span style="color: #DD0000">"Content-Type: </span><span style="color: #007700">{</span><span style="color: #0000BB">$response_info</span><span style="color: #007700">[</span><span style="color: #DD0000">"content_type"</span><span style="color: #007700">]}</span><span style="color: #DD0000">"</span><span style="color: #007700">);<br />    echo </span><span style="color: #0000BB">$oauth</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getLastResponse</span><span style="color: #007700">();<br />} catch(</span><span style="color: #0000BB">OAuthException $E</span><span style="color: #007700">) {<br />    echo </span><span style="color: #DD0000">"Exception caught!\n"</span><span style="color: #007700">;<br />    echo </span><span style="color: #DD0000">"Response: "</span><span style="color: #007700">. </span><span style="color: #0000BB">$E</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">lastResponse </span><span style="color: #007700">. </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-oauth.fetch-seealso">
  <h3 class="title">See Also</h3>
  <ul class="simplelist">
   <li><span class="methodname"><a href="oauth.getlastresponse.php" class="methodname" rel="rdfs-seeAlso">OAuth::getLastResponse()</a> - Get the last response</span></li>
   <li><span class="methodname"><a href="oauth.getlastresponseinfo.php" class="methodname" rel="rdfs-seeAlso">OAuth::getLastResponseInfo()</a> - Get HTTP information about the last response</span></li>
   <li><span class="methodname"><a href="oauth.settoken.php" class="methodname" rel="rdfs-seeAlso">OAuth::setToken()</a> - Sets the token and secret</span></li>
  </ul>
 </div>


</div><?php manual_footer($setup); ?>