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

<refentry xml:id="oauth.getaccesstoken" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
 <refnamediv>
  <refname>OAuth::getAccessToken</refname>
  <refpurpose>Fetch an access token</refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <modifier>public</modifier> <type>array</type><methodname>OAuth::getAccessToken</methodname>
   <methodparam><type>string</type><parameter>access_token_url</parameter></methodparam>
   <methodparam choice="opt"><type>string</type><parameter>auth_session_handle</parameter></methodparam>
   <methodparam choice="opt"><type>string</type><parameter>verifier_token</parameter></methodparam>
   <methodparam choice="opt"><type>string</type><parameter>http_method</parameter></methodparam>
  </methodsynopsis>
  <para>
   Fetch an access token, secret and any additional response parameters from the service provider.
  </para>
 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <para>
   <variablelist>
    <varlistentry>
     <term><parameter>access_token_url</parameter></term>
     <listitem>
      <para>
       URL to the access token API.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>auth_session_handle</parameter></term>
     <listitem>
      <para>
       Authorization session handle, this parameter does not have any
       citation in the core OAuth 1.0 specification but may be 
       implemented by large providers. 
       <link xlink:href="&url.oauth.scale;">See ScalableOAuth</link>
       for more information.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>verifier_token</parameter></term>
     <listitem>
      <para>
       For service providers which support 1.0a, a <parameter>verifier_token</parameter>
       must be passed while exchanging the request token for the access
       token. If the <parameter>verifier_token</parameter> is present in <parameter>$_GET</parameter> 
       or <parameter>$_POST</parameter> it is passed automatically and the caller 
       does not need to specify a <parameter>verifier_token</parameter> (usually if the access token 
       is exchanged at the oauth_callback URL).
       <link xlink:href="&url.oauth.scale;">See ScalableOAuth</link>
       for more information.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>http_method</parameter></term>
     <listitem>
      <para>
       HTTP method to use, e.g. <literal>GET</literal> or <literal>POST</literal>.
      </para>
     </listitem>
    </varlistentry>
   </variablelist>
  </para>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   Returns an array containing the parsed OAuth response on success or &false; on failure.
  </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.9</entry>
       <entry>
        The <parameter>verifier_token</parameter> parameter was added
       </entry>
      </row>
     </tbody>
    </tgroup>
   </informaltable>
  </para>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <para>
   <example>
    <title><function>OAuth::getAccessToken</function> example</title>
    <programlisting role="php">
<![CDATA[
<?php
try {
    $oauth = new OAuth(OAUTH_CONSUMER_KEY,OAUTH_CONSUMER_SECRET);
    $oauth->setToken($request_token,$request_token_secret);
    $access_token_info = $oauth->getAccessToken("https://example.com/oauth/access_token");
    if(!empty($access_token_info)) {
        print_r($access_token_info);
    } else {
        print "Failed fetching access token, response was: " . $oauth->getLastResponse();
    }
} catch(OAuthException $E) {
    echo "Response: ". $E->lastResponse . "\n";
}
?>
]]>
    </programlisting>
    &example.outputs.similar;
    <screen>
<![CDATA[
Array
(
    [oauth_token] => some_token
    [oauth_token_secret] => some_token_secret
)
]]>
    </screen>
   </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
-->
