cURL for instead of php file_get_contents core function


Please try following custom function to get file contents via cURL.


<?php
function file_get_contents_curl($url) {
    $ch = curl_init();

    curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);       

    $data = curl_exec($ch);
    curl_close($ch);

    return $data;
}

?>
Share on Google Plus

About srimaster

Tech Dropper is simple, easy and newest technology source with experiments and demos. I will give you tutorials, notes, code snippets, demos using PHP, MySQL, jQuery, HTML, CSS, Ajax and Javascripts.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment