title: Getting JSON response with PHP
body: <p>I'm trying to connect an API that uses 0AUTH2 via PHP. The original plan was to use client-side JS, but that isn't possible with 0AUTH2.</p>
  
  <p>I'm simply trying get a share count from the API's endpoint which is here:
  https://api.bufferapp.com/1/links/shares.json?url=[your-url-here]&amp;access_token=[your-access-key-here]</p>
  
  <p>I do have a proper access_token that I am using to access the json file, that is working fine.</p>
  
  <p>This is the code I have currently written, but I'm not even sure I'm on the right track.</p>
  
  <pre><code>// 0AUTH2 ACCESS TOKEN FOR AUTHENTICATION
  $key = '[my-access-key-here]';
  
  // JSON URL TO BE REQUESTED
  $json_url = 'https://api.bufferapp.com/1/links/shares.json?url=http://bufferapp.com&amp;access_token=' . $key;
  
  // GET THE SHARE COUNT FROM THE REQUEST
  $json_string = '[shares]';
  
  // INITIALIZE CURL
  $ch = curl_init( $json_url );
  
  
  // CONFIG CURL OPTIONS
  $options = array(
      CURLOPT_RETURNTRANSFER  =&gt; true,
      CURLOPT_HTTPHEADER      =&gt; array('Content-type: application/json') ,
      CURLOPT_POSTFIELDS      =&gt; $json_string
  );
  
  // SETTING CURL AOPTIONS
  curl_setopt_array( $ch, $options );
  
  // GET THE RESULTS
  $result =  curl_exec($ch); // Getting jSON result string
  </code></pre>
  
  <p>Like I said, I don't know if this is the best method - so I'm open to any suggestions. 
  I'm just trying to retrieve the share count with this PHP script, then with JS, spit out the share count where I need it on the page.</p>