3

I use this code:

$this->curl = curl_init(); curl_setopt($this->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($this->curl, CURLOPT_TIMEOUT, 60); curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($this->curl, CURLOPT_PROXY, '127.0.0.1:9050'); curl_setopt($this->curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($this->curl, CURLOPT_URL, "http://some-onion-site.onion"); $contents = curl_exec($this->curl); 

It's returns nothing instantly. Tor is working normally, and site is accessible from tor browser. Edit: I've found that it can't resolve host ("Couldn't resolve host name" error).

2
  • 1
    Use curl_error() to see what goes wrong Commented Aug 25, 2013 at 16:46
  • @Pekka웃 I've edited the question. It can't resolve the hostname. Commented Aug 25, 2013 at 16:49

1 Answer 1

1

Well, I've found out that I need to set proxy type to CURLPROXY_SOCKS5_HOSTNAME:

curl_setopt($ch, CURLOPT_PROXYTYPE, 7); 

It works fine.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.