<?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 => 'pt_BR',
  ),
  'this' => 
  array (
    0 => 'oauth.getrequesttoken.php',
    1 => 'OAuth::getRequestToken',
    2 => 'Busca um token de requisi&ccedil;&atilde;o',
  ),
  'up' => 
  array (
    0 => 'class.oauth.php',
    1 => 'OAuth',
  ),
  'prev' => 
  array (
    0 => 'oauth.getrequestheader.php',
    1 => 'OAuth::getRequestHeader',
  ),
  'next' => 
  array (
    0 => 'oauth.setauthtype.php',
    1 => 'OAuth::setAuthType',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'pt_BR',
    'path' => 'reference/oauth/oauth/getrequesttoken.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="oauth.getrequesttoken" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">OAuth::getRequestToken</h1>
  <p class="verinfo">(PECL OAuth &gt;= 0.99.1)</p><p class="refpurpose"><span class="refname">OAuth::getRequestToken</span> &mdash; <span class="dc-title">Busca um token de requisição</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-oauth.getrequesttoken-description">
  <h3 class="title">Descrição</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>OAuth::getRequestToken</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$request_token_url</code></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$callback_url</code><span class="initializer"> = ?</span></span>, <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>): <span class="type"><a href="language.types.array.php" class="type array">array</a></span></div>

  <p class="simpara">
   Busca um token de requisição, segredo e quaisquer parâmetros de resposta adicionais do provedor de serviço.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-oauth.getrequesttoken-parameters">
  <h3 class="title">Parâmetros</h3>
  <dl>
   
    <dt><code class="parameter">request_token_url</code></dt>
    <dd>
     <span class="simpara">
      URL para a API do token de requisição.
     </span>
    </dd>
   
   
    <dt><code class="parameter">callback_url</code></dt>
    <dd>
     <span class="simpara">
      URL de chamada de retorno OAuth. Se <code class="parameter">callback_url</code> for informado e for um valor, é definido para &quot;oob&quot; para endereçar o alerta OAuth 2009.1.
     </span>
    </dd>
   
   
    <dt><code class="parameter">http_method</code></dt>
    <dd>
     <span class="simpara">
      Método HTTP a ser usado, ex.: <code class="literal">GET</code> ou <code class="literal">POST</code>.
     </span>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-oauth.getrequesttoken-returnvalues">
  <h3 class="title">Valor Retornado</h3>
  <p class="simpara">
   Retorna um array contendo a resposta OAuth interpretada em caso de sucesso ou <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> em caso de falha.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-oauth.getrequesttoken-changelog">
  <h3 class="title">Registro de Alterações</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Versão</th>
      <th>Descrição</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>PECL oauth 1.0.0</td>
      <td>
       Anteriormente, retornava <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> em caso de falha, em vez de <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
      </td>
     </tr>

     <tr>
      <td>PECL oauth 0.99.9</td>
      <td>
       O parâmetro <code class="parameter">callback_url</code> foi adicionado
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-oauth.getrequesttoken-examples">
  <h3 class="title">Exemplos</h3>
  <div class="example" id="example-1">
   <p><strong>Exemplo #1 Exemplo de <span class="function"><strong>OAuth::getRequestToken()</strong></span></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: #0000BB">OAUTH_CONSUMER_KEY</span><span style="color: #007700">,</span><span style="color: #0000BB">OAUTH_CONSUMER_SECRET</span><span style="color: #007700">);<br />    </span><span style="color: #0000BB">$request_token_info </span><span style="color: #007700">= </span><span style="color: #0000BB">$oauth</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getRequestToken</span><span style="color: #007700">(</span><span style="color: #DD0000">"https://example.com/oauth/request_token"</span><span style="color: #007700">);<br />    if(!empty(</span><span style="color: #0000BB">$request_token_info</span><span style="color: #007700">)) {<br />        </span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$request_token_info</span><span style="color: #007700">);<br />    } else {<br />        print </span><span style="color: #DD0000">"Falha ao buscar token de requisição, resposta foi: " </span><span style="color: #007700">. </span><span style="color: #0000BB">$oauth</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getLastResponse</span><span style="color: #007700">();<br />    }<br />} catch(</span><span style="color: #0000BB">OAuthException $E</span><span style="color: #007700">) {<br />    echo </span><span style="color: #DD0000">"Resposta: "</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 class="example-contents"><p>O exemplo acima produzirá
algo semelhante a:</p></div>
   <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">Array
(
    [oauth_token] =&gt; algum_token
    [oauth_token_secret] =&gt; algum_segredo_de_token
)</pre>
</div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-oauth.getrequesttoken-seealso">
  <h3 class="title">Veja Também</h3>
  <ul class="simplelist">
   <li><span class="methodname"><a href="oauth.getlastresponse.php" class="methodname" rel="rdfs-seeAlso">OAuth::getLastResponse()</a> - Obt&eacute;m a &uacute;ltima resposta</span></li>
   <li><span class="methodname"><a href="oauth.getlastresponseinfo.php" class="methodname" rel="rdfs-seeAlso">OAuth::getLastResponseInfo()</a> - Obt&eacute;m informa&ccedil;&atilde;o HTTP sobre a &uacute;ltima resposta</span></li>
  </ul>
 </div>


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