Skip to main content

If you want to fetch a file from another server, PHP can be used.

Example, I want to download the Clickbank Product XML file, also known as the Marketplace feed, from Clickbank and store it on my server.

The Clickbank Marketplace XML feed address is

I can create a PHP file that will fetch it like this:



$fileToFetch = '';

$whereToSave = fopen(dirname(__FILE__) . '/', 'w+');

$curl = curl_init($fileToFetch);

curl_setopt_array($curl, [

CURLOPT_URL     => $fileToFetch,



CURLOPT_FILE    => $whereToSave,




$response = curl_exec($curl);

if ($response === false) {

throw new \Exception('Curl error: ' . curl_error($curl));





Just so you know, you'll need the PHP curl extension installed. On Debian or Ubuntu, you can install it by:

sudo apt-get install php-curl

You'll know you don't have php-curl installed if you get an error like the following:

PHP Fatal error:  Uncaught Error: Call to undefined function curl_init()