title: Getting image data using the Imgur API and PHP
body: <p>I'm quite new to php and I'm trying to use the imgur API (My code is based on several tutorials) What I'm trying to do is get an image from imgur display it on a web page. So I'm using this code</p>
  
  <pre><code>&lt;?php  
    $client_id = '&lt;ID&gt;';
  
    $ch = curl_init();
    curl_setopt($ch,CURLOPT_URL,'https://api.imgur.com/3/image/rnXusiA');
    curl_setopt($ch,CURLOPT_CONNECTTIMEOUT, 5);
    curl_setopt($ch,CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Client-ID ' . $client_id));
    $result = curl_exec($ch);
    curl_close($ch);
  
    $json = json_decode($result, true);
  ?&gt;
  </code></pre>
  
  <p>After converting <code>$result</code> to an associative array, I'm trying to access data </p>
  
  <p><code>$data = $json-&gt;data-&gt;link;</code></p>
  
  <p>But there's nothing in <code>$data</code> and I'm getting a <code>Trying to get property of non-object</code> error. I'm assuming imgur didn't return any data. So what am I doing wrong?</p>