title: Put GET values in PHP Curl request header
body: <p>The API I'm requesting is expecting a <code>GET</code> HTTP method</p>
  
  <p>I want to avoid something like</p>
  
  <p><code>domain.com/api/v1/module/user?access_token=er78e9wr7fasf7s9a8fsd7fa8f7sa8f</code> for example.</p>
  
  <p>I'd rather be able to request</p>
  
  <p><code>domain.com/api/v1/module/user</code>
  and set the access_token value in the header, I'm aware you can do this with post, but I'd like to do this for a GET method.</p>
  
  <p>I currently have the following</p>
  
  <pre><code>    public function fetch() 
      {
          $response = json_decode(
              $this-&gt;prepareRequest(
                  new \Web\Curl\Wrapper,
                  $this-&gt;prepareRequestURL()
              )-&gt;execute()
          );
      }
      private function prepareRequestURL()
      {
          return $this-&gt;apiConfig-&gt;getBaseDomain() . $this-&gt;apiConfig-&gt;getUserSelfURL();
      }
  
      private function prepareRequest(\Web\Curl\Wrapper $curlWrapper, $url)
      {
          $curlWrapper-&gt;init($url);
          $curlWrapper-&gt;setOption(CURLOPT_RETURNTRANSFER, 1);
          $curlWrapper-&gt;setOption(CURLOPT_HTTPHEADER, array(
              $this-&gt;apiConfig-&gt;getAccessTokenKey() =&gt; $_SESSION[$this-&gt;apiConfig-&gt;getAccessTokenKey()]
          ));
          return $curlWrapper;
      }
  </code></pre>
  
  <p>My curl wrapper class</p>
  
  <pre><code>private $curl;
  
  public function init($requestLocation = null)
  {
      $this-&gt;curl = curl_init($requestLocation);
  }
  
  public function preparePost($postData)
  {
      $this-&gt;setOption(CURLOPT_POST, 4);
      $this-&gt;setOption(CURLOPT_POSTFIELDS, $postData);
      $this-&gt;setOption(CURLOPT_SSL_VERIFYPEER, false);
      $this-&gt;setOption(CURLOPT_RETURNTRANSFER, true);
  }
  
  public function execute()
  {
      return curl_exec($this-&gt;curl);
  }
  
  public function setOption($option, $value)
  {
      curl_setopt($this-&gt;curl, $option, $value);
  }
  </code></pre>