title: How to use oAuth with Guzzle 5 (or, better, with Guzzle 6)
body: <p>I'm trying to connect to the WooCommerce API using Guzzle 5 (Guzzle 6 seems not has oAuth options o.O). Woocommerce <a href="http://woothemes.github.io/woocommerce-rest-api-docs/#authentication" rel="nofollow">requires the oAuth authentication method</a> to work.</p>
  
  <p>This is the code I'm using:</p>
  
  <pre><code>&lt;?php
  
  /**
   * Example of usage of Guzzle 5 to get information
   * from a WooCommerce Store.
   */
  
  require('../vendor/autoload.php');
  
  use GuzzleHttp\Client;
  use GuzzleHttp\Subscriber\Oauth\Oauth1;
  use GuzzleHttp\Exception\RequestException;
  
  $consumer_key = 'my_consumer_key'; // Add your own Consumer Key here
  $consumer_secret = 'my_consumer_secret'; // Add your own Consumer Secret here
  $store_url = 'http://example.com'; // Add the home URL to the store you want to connect to here
  $api_path = '/wc-api/v2/';
  $api_end_point = [
      'root' =&gt; '',
      'orders' =&gt; 'orders'
      ];
  
  $base_uri = $store_url . $api_path;
  
  $client = new Client([
      'base_url' =&gt; $base_uri,
      'defaults' =&gt; ['auth' =&gt; 'oauth']
      ]);
  
  $oauth = new Oauth1([
      'consumer_key'    =&gt; $consumer_key,
      'consumer_secret' =&gt; $consumer_secret,
      'request_method'  =&gt; 'query'
  ]);
  
  $client-&gt;getEmitter()-&gt;attach($oauth);
  
  try
  {
      $res = $client-&gt;get($api_end_point['orders']);
  }
  catch (RequestException $e)
  {
      $res = $e;
  
      if ($e-&gt;hasResponse())
      {
          $res = $e-&gt;getResponse();
      }
  }
  
  print_r($res);
  
  echo $res-&gt;getStatusCode();
  // "200"
  echo $res-&gt;getHeader('content-type');
  // 'application/json; charset=utf8'
  echo $res-&gt;getBody();
  // {"type":"User"...'
  </code></pre>
  
  <p>This code returns a </p>
  
  <blockquote>
    <p>woocommerce_api_authentication_error: Invalid Signature - provided
    signature does not match</p>
  </blockquote>
  
  <p>Using pure curl functions (using <a href="https://github.com/Aerendir/APIConnect/blob/master/src/APIConnect.php" rel="nofollow">this package</a> in which I've put some functions I found <a href="https://github.com/kloon/WooCommerce-REST-API-Client-Library" rel="nofollow">here</a>), instead, it works and I get all orders and other data I want.</p>
  
  <p><strong>SOME OTHER DETAILS</strong></p>
  
  <p>To use Guzzle 5 and oAuth I use the those composer packages:</p>
  
  <pre><code>"require": {
      "guzzlehttp/guzzle": "~5.0"
  },
  "require-dev": {
      "guzzlehttp/oauth-subscriber": "~0.2",
  },
  </code></pre>
  
  <p>It seems there are some things that are different in creating the signature: the one created by <a href="https://github.com/kloon/WooCommerce-REST-API-Client-Library" rel="nofollow">the library I've used until now</a> works, but the one created by the oAuth plugin (<a href="https://github.com/guzzle/oauth-subscriber/blob/master/src/Oauth1.php#L112-L162" rel="nofollow">using the method <code>getSignature()</code></a>) for Guzzle doesn't and I'm not so used to use oAuth to find the error. Is there someone who can help me identify the problem?</p>