title: How to get data from API - php - curl
body: <p>How can I get data ( image ) from api url?</p>
  
  <p>Api result:</p>
  
  <pre><code>info = { "title" : "aaaaa", "image" : "bbbbb" };
  </code></pre>
  
  <p>Api url:</p>
  
  <pre><code>http://www.example.com/api
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>&lt;?php
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_URL, 'http://www.example.com/api');
  $result = curl_exec($ch);
  curl_close($ch);
  $obj = json_decode($result);
  echo $result-&gt;image;
  ?&gt;
  </code></pre>
  
  
  
  <pre><code>Array
  (
      [curlResult] =&gt; info = { "title" : "aaaaa", "image" : "bbbbb" };
      [info] =&gt; Array
          (
              [url] =&gt; http://127.0.0.1/api.txt
              [content_type] =&gt; text/plain
              [http_code] =&gt; 200
              [header_size] =&gt; 237
              [request_size] =&gt; 55
              [filetime] =&gt; -1
              [ssl_verify_result] =&gt; 0
              [redirect_count] =&gt; 0
              [total_time] =&gt; 0
              [namelookup_time] =&gt; 0
              [connect_time] =&gt; 0
              [pretransfer_time] =&gt; 0
              [size_upload] =&gt; 0
              [size_download] =&gt; 48
              [speed_download] =&gt; 48
              [speed_upload] =&gt; 0
              [download_content_length] =&gt; 48
              [upload_content_length] =&gt; 0
              [starttransfer_time] =&gt; 0
              [redirect_time] =&gt; 0
              [certinfo] =&gt; Array
                  (
                  )
  
              [primary_ip] =&gt; 127.0.0.1
              [primary_port] =&gt; 80
              [local_ip] =&gt; 127.0.0.1
              [local_port] =&gt; 61662
              [redirect_url] =&gt; 
          )
  
      [errno] =&gt; 0
      [error] =&gt; 
  )
  </code></pre>