Get file content via PHP cURL [closed]

You can use file_get_contents as Petr says, but you need to activate allow_url_fopen in your php.ini and perhaps your hosting do not allow you to change this.

If you prefer to use CURL instead of file_get_contents, try this code:

<?php
$url="http://www.adserversite.com/ads.php";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
$data = curl_exec($curl);
curl_close($curl);

Leave a Comment