So I'm trying to cURL to an onion site, e.g: facebookcorewwwi.onion
I would have the following code:
<?php
$curl = curl_init();
curl_setopt($curl, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
curl_setopt($curl, CURLOPT_URL, 'http://facebookcorewwwi.onion/');
curl_setopt($curl, CURLOPT_TIMEOUT, 60);
curl_setopt($curl, CURLOPT_HTTPGET, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_PROXY, '127.0.0.1:9050');
curl_setopt($curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE);
$html = curl_exec($curl);
var_dump($html);
From the php docs for curl_exec
:
Returns TRUE on success or FALSE on failure. However, if the CURLOPT_RETURNTRANSFER option is set, it will return the result on success, FALSE on failure.
If curl_exec
is returning a boolean of false, an error has occurred. Try fetching the error:
$html = curl_exec($curl);
if ( $html === false ) {
echo 'Error: ' . curl_error($curl);
}