Recently I found php curl can't get info from Tor V3.onoin. When I try to curl v3 domain it return CURLE_COULDNT_CONNECT. My method is ok on v2. Here's an domain example. v3 domain:http://vww6ybal4bd7szmgncyruucpgfkqahzddi37ktceo3ah7ngmcopnpyyd.onion/ v2 domain:http://torbox3uiot6wchz.onion/
Here's my code.
<?php
function get_content($url, $cookie)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_USERAGENT, $GLOBALS ['user_agent']);
curl_setopt($ch, CURLOPT_PROXY, "http://127.0.0.1:9150/");
curl_setopt($ch, CURLOPT_PROXYTYPE, 7);
$return = curl_exec($ch);
$errno = curl_errno($ch);
$info = curl_getinfo($ch);
$info['errno'] = $errno;
$log = json_encode($info);
putLog($log);
curl_close($ch);
return $return;
}
function putLog($log)
{
$log .= "nn";
$logDir = dirname(__FILE__);
$logPath = $logDir . "/curl_log.txt";
if (!file_exists($logPath)) {
$handle = fopen($logPath, 'w');
fclose($handle);
}
file_put_contents($logPath, $log, FILE_APPEND);
}
$cookie = dirname(__FILE__) . '/cookie_ydma.txt';
$output_first = get_content("http://torbox3uiot6wchz.onion/", $cookie);
echo $output_first;
?>