<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Fetch a request token</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="oauth.getrequestheader.html">OAuth::getRequestHeader</a></div> <div class="next" style="text-align: right; float: right;"><a href="oauth.setauthtype.html">OAuth::setAuthType</a></div> <div class="up"><a href="class.oauth.html">OAuth</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="oauth.getrequesttoken" class="refentry"> <div class="refnamediv"> <h1 class="refname">OAuth::getRequestToken</h1> <p class="verinfo">(PECL OAuth >= 0.99.1)</p><p class="refpurpose"><span class="refname">OAuth::getRequestToken</span> — <span class="dc-title">Fetch a request token</span></p> </div> <div class="refsect1 description" id="refsect1-oauth.getrequesttoken-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">array</span> <span class="methodname"><strong>OAuth::getRequestToken</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$request_token_url</code></span> [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$callback_url</code></span> ] )</div> <p class="para rdfs-comment"> Fetch a request token, secret and any additional response parameters from the service provider. </p> </div> <div class="refsect1 parameters" id="refsect1-oauth.getrequesttoken-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">request_token_url</code></em></span> <dd> <p class="para"> URL to the request token API. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">callback_url</code></em></span> <dd> <p class="para"> OAuth callback URL. If <em><code class="parameter">callback_url</code></em> is passed and is an empty value, it is set to "oob" to address the OAuth 2009.1 advisory. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-oauth.getrequesttoken-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns an array containing the parsed OAuth response on success or <strong><code>FALSE</code></strong> on failure. </p> </div> <div class="refsect1 changelog" id="refsect1-oauth.getrequesttoken-changelog"> <h3 class="title">Changelog</h3> <p class="para"> <table class="doctable informaltable"> <thead> <tr> <th>Version</th> <th>Description</th> </tr> </thead> <tbody class="tbody"> <tr> <td>1.0.0</td> <td> Previously returned <strong><code>NULL</code></strong> on failure, instead of <strong><code>FALSE</code></strong>. </td> </tr> <tr> <td>0.99.9</td> <td> The <em><code class="parameter">callback_url</code></em> parameter was added </td> </tr> </tbody> </table> </p> </div> <div class="refsect1 examples" id="refsect1-oauth.getrequesttoken-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-5285"> <p><strong>Example #1 <span class="function"><strong>OAuth::getRequestToken()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?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">-></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">"Failed fetching request token, response was: " </span><span style="color: #007700">. </span><span style="color: #0000BB">$oauth</span><span style="color: #007700">-></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">"Response: "</span><span style="color: #007700">. </span><span style="color: #0000BB">$E</span><span style="color: #007700">-></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">?></span> </span> </code></div> </div> <div class="example-contents"><p>The above example will output something similar to:</p></div> <div class="example-contents screen"> <div class="cdata"><pre> Array ( [oauth_token] => some_token [oauth_token_secret] => some_token_secret ) </pre></div> </div> </div> </p> </div> <div class="refsect1 seealso" id="refsect1-oauth.getrequesttoken-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="methodname"><a href="oauth.getlastresponse.html" class="methodname" rel="rdfs-seeAlso">OAuth::getLastResponse()</a> - Get the last response</span></li> <li class="member"> <span class="methodname"><a href="oauth.getlastresponseinfo.html" class="methodname" rel="rdfs-seeAlso">OAuth::getLastResponseInfo()</a> - Get HTTP information about the last response</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="oauth.getrequestheader.html">OAuth::getRequestHeader</a></div> <div class="next" style="text-align: right; float: right;"><a href="oauth.setauthtype.html">OAuth::setAuthType</a></div> <div class="up"><a href="class.oauth.html">OAuth</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>