<?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 => 'ja',
  ),
  'this' => 
  array (
    0 => 'oauth.fetch.php',
    1 => 'OAuth::fetch',
    2 => 'OAuth で保護されたリソースを取得する',
  ),
  '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' => 'ja',
    '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">OAuth で保護されたリソースを取得する</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-oauth.fetch-description">
  <h3 class="title">説明</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">
   リソースを取得します。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-oauth.fetch-parameters">
  <h3 class="title">パラメータ</h3>
  <dl>
   
    <dt><code class="parameter">protected_resource_url</code></dt>
    <dd>
     <span class="simpara">
      OAuth で保護されたリソースへの URL。
     </span>
    </dd>
   
   
    <dt><code class="parameter">extra_parameters</code></dt>
    <dd>
     <span class="simpara">
      リソースへのリクエストとともに送信する追加パラメータ。
     </span>
    </dd>
   
   
    <dt><code class="parameter">http_method</code></dt>
    <dd>
     <span class="simpara">
      <strong><code><a href="oauth.constants.php#constant.oauth-http-method-get">OAUTH_HTTP_METHOD_<span class="replaceable">*</span></a></code></strong> OAUTH 定数 のいずれか。
      GET、POST、PUT、HEAD そして 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>) は、
      実際のリクエストの前に
      (OAuth 認証情報が <code class="literal">Authorization</code> ヘッダにあるかどうかなどの)
      情報を取得するときに有用です。
     </span>
    </dd>
   
   
    <dt><code class="parameter">http_headers</code></dt>
    <dd>
     <span class="simpara">
      HTTP クライアントヘッダ (User-Agent や Accept など)。
     </span>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-oauth.fetch-returnvalues">
  <h3 class="title">戻り値</h3>
  <p class="simpara">
   成功した場合に <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> を、失敗した場合に <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> を返します。
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-oauth.fetch-changelog">
  <h3 class="title">変更履歴</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>バージョン</th>
      <th>説明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>PECL oauth 1.0.0</td>
      <td>
       以前は、失敗したときに <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> ではなく <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> を返していました。
      </td>
     </tr>

     <tr>
      <td>PECL oauth 0.99.5</td>
      <td>
       <code class="parameter">http_method</code> パラメータが追加されました。
      </td>
     </tr>

     <tr>
      <td>PECL oauth 0.99.8</td>
      <td>
       <code class="parameter">http_headers</code> パラメータが追加されました。
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-oauth.fetch-examples">
  <h3 class="title">例</h3>
  <div class="example" id="example-1">
   <p><strong>例1 <span class="function"><strong>OAuth::fetch()</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: #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">参考</h3>
  <ul class="simplelist">
   <li><span class="methodname"><a href="oauth.getlastresponse.php" class="methodname" rel="rdfs-seeAlso">OAuth::getLastResponse()</a> - 直近のレスポンスを取得する</span></li>
   <li><span class="methodname"><a href="oauth.getlastresponseinfo.php" class="methodname" rel="rdfs-seeAlso">OAuth::getLastResponseInfo()</a> - 直近のレスポンスの HTTP 情報を取得する</span></li>
   <li><span class="methodname"><a href="oauth.settoken.php" class="methodname" rel="rdfs-seeAlso">OAuth::setToken()</a> - トークンと secret を設定する</span></li>
  </ul>
 </div>


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