3

I'm trying todo a simple curl with a hashtag in target url - but getting errors.

I know this script works, i've used it many times before.

<?php

error_reporting(E_ALL);

$curl = curl_init('http://tools.pingdom.com/fpt/#!/d3YvU8/http://www.nginx-hosting.co.uk');
curl_setopt($curl, CURLOPT_FAILONERROR, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);  
$result = curl_exec($curl);

if ($result == ("")) {
echo ("Nothing to curl");
}
else {
echo $result;
}

?> 

Here is the above script in action: http://www.nginx-hosting.co.uk/curl_test.php

As you can see the ouput is nothing like it's supposed to be. I ran the same command through SSH :

curl http://tools.pingdom.com/fpt/#!/d3YvU8/http://www.nginx-hosting.co.uk

But get this error message -bash: !/d3YvU8/http: event not found

I assume this is because the target url has an exclamation mark in it or a hashtag.

Could someone point me in the right direction please. Thanks in advance

1 Answers1

3

I just tried your script it works just fine, about -bash: !/d3YvU8/http: event not found error you should use quotes like: curl ' http://tools.pingdom.com/fpt/#!/d3YvU8/http://www.nginx-hosting.co.uk'

Aurimas Ličkus
  • 9,886
  • 4
  • 24
  • 26