<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->

<refentry xml:id="oauth.fetch" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
 <refnamediv>
  <refname>OAuth::fetch</refname>
  <refpurpose>Fetch an OAuth protected resource</refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <modifier>public</modifier> <type>mixed</type><methodname>OAuth::fetch</methodname>
   <methodparam><type>string</type><parameter>protected_resource_url</parameter></methodparam>
   <methodparam choice="opt"><type>array</type><parameter>extra_parameters</parameter></methodparam>
   <methodparam choice="opt"><type>string</type><parameter>http_method</parameter></methodparam>
   <methodparam choice="opt"><type>array</type><parameter>http_headers</parameter></methodparam>
  </methodsynopsis>
  <para>
   Fetch a resource.
  </para>
 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <para>
   <variablelist>
    <varlistentry>
     <term><parameter>protected_resource_url</parameter></term>
     <listitem>
      <para>
       URL to the OAuth protected resource.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>extra_parameters</parameter></term>
     <listitem>
      <para>
       Extra parameters to send with the request for the resource.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>http_method</parameter></term>
     <listitem>
      <para>
       One of the <constant>OAUTH_HTTP_METHOD_*</constant>
       <link linkend="oauth.constants">OAUTH constants</link>, which includes
       GET, POST, PUT, HEAD, or DELETE.
      </para>
      <para>
       HEAD (<constant>OAUTH_HTTP_METHOD_HEAD</constant>) can be useful for
       discovering information prior to the request (if OAuth credentials are
       in the <literal>Authorization</literal> header).
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>http_headers</parameter></term>
     <listitem>
      <para>
       HTTP client headers (such as User-Agent, Accept, etc.)
      </para>
     </listitem>
    </varlistentry>
   </variablelist>
  </para>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   &return.success;
  </para>
 </refsect1>

 <refsect1 role="changelog">
  &reftitle.changelog;
  <para>
   <informaltable>
    <tgroup cols="2">
     <thead>
      <row>
       <entry>&Version;</entry>
       <entry>&Description;</entry>
      </row>
     </thead>
     <tbody>
      <row>
       <entry>PECL oauth 1.0.0</entry>
       <entry>
        &oauth.changelog.error.null;
       </entry>
      </row>
      <row>
       <entry>PECL oauth 0.99.5</entry>
       <entry>
        The <parameter>http_method</parameter> parameter was added
       </entry>
      </row>
      <row>
       <entry>PECL oauth 0.99.8</entry>
       <entry>
        The <parameter>http_headers</parameter> parameter was added
       </entry>
      </row>
     </tbody>
    </tgroup>
   </informaltable>
  </para>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <para>
   <example>
    <title><function>OAuth::fetch</function> example</title>
    <programlisting role="php">
<![CDATA[
<?php
try {
    $oauth = new OAuth("consumer_key","consumer_secret",OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_AUTHORIZATION);
    $oauth->setToken("access_token","access_token_secret");

    $oauth->fetch("http://photos.example.net/photo?file=vacation.jpg");

    $response_info = $oauth->getLastResponseInfo();
    header("Content-Type: {$response_info["content_type"]}");
    echo $oauth->getLastResponse();
} catch(OAuthException $E) {
    echo "Exception caught!\n";
    echo "Response: ". $E->lastResponse . "\n";
}
?>
]]>
    </programlisting>
   </example>
  </para>
 </refsect1>

 <refsect1 role="seealso">
  &reftitle.seealso;
  <para>
   <simplelist>
    <member><methodname>OAuth::getLastResponse</methodname></member>
    <member><methodname>OAuth::getLastResponseInfo</methodname></member>
    <member><methodname>OAuth::setToken</methodname></member>
   </simplelist>
  </para>
 </refsect1>

</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
