Get API value using curl

<?php 
 $url = 'YOUR_API_LINK';
                  $crl = curl_init();
                  
                  curl_setopt($crl, CURLOPT_URL, $url);
                  curl_setopt($crl, CURLOPT_FRESH_CONNECT, true);
                  curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
                  $response = curl_exec($crl);
                  curl_close($crl);

$respons1 = json_decode($response, true); //because of true, it's in an array

//DISPLAY ALL VALUE IN FORMATTING 
echo "<pre>";
print_r($response);
echo "</pre>";

//FOR GETTING VALUE IN  LOOP
foreach ($response as $r) {
    echo $r['CONTENT_NAME'].'</br>';
}
?>

Leave a Reply

Your email address will not be published.

You may use these <abbr title="HyperText Markup Language">html</abbr> tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*

%d bloggers like this: