cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: configuring curl with proxy servers

From: Pragya Ratna Bajracharya <pragyabchar_at_gmail.com>
Date: Tue, 1 Jul 2008 09:09:50 +0545

I updated the below code to the following:
<?php
$ch = curl_init();
curl_setopt ($ch, CURLOPT_PROXY, "xx.xxx.xx.xx:8080");
curl_setopt ($ch, CURLOPT_HTTPPROXYTUNNEL, 0);
curl_setopt($ch,CURLOPT_VERBOSE,true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_COOKIEJAR,"cookie.txt");
curl_setopt($ch,CURLOPT_COOKIEFILE,1);
curl_setopt($ch, CURLOPT_URL,"http://www.example.com");
$response = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
var_dump($info);
echo $response;
?>

the curl info shows the following details:
array
  'url' => string 'http://www.example.com' (length=32)
  'http_code' => int 0
  'header_size' => int 0
  'request_size' => int 0
  'filetime' => int -1
  'ssl_verify_result' => int 0
  'redirect_count' => int 0
  'total_time' => float 0
  'namelookup_time' => float 0
  'connect_time' => float 0
  'pretransfer_time' => float 0
  'size_upload' => float 0
  'size_download' => float 0
  'speed_download' => float 0
  'speed_upload' => float 0
  'download_content_length' => float 0
  'upload_content_length' => float 0
  'starttransfer_time' => float 0
  'redirect_time' => float 0

however the response is still not being available.

2008/6/30 haroon ahmad <haroon_at_fastcreators.com>:

> Have you dont http sniffing to see if the proxy works like this on itself?
> it might use some session/cookie that you will have to pass in cURL session
> to successfully use proxy.
>
> Regards,
> Haroon Ahmad
> Expert Offshore Web Developer
>
> 2008/6/30 Pragya Ratna Bajracharya <pragyabchar_at_gmail.com>:
>
>> Hello all,
>>
>> Based on this following example
>>
>> <?
>>
>> $ch = curl_init();
>>
>> curl_setopt($ch, CURLOPT_URL, 'http://www.example.com');
>>
>> curl_setopt($ch, CURLOPT_HEADER, 1);
>>
>> curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
>>
>> curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
>>
>> curl_setopt($ch, CURLOPT_PROXY, 'fakeproxy.com:1080');
>>
>> curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'user:password');
>>
>> $data = curl_exec();
>>
>> curl_close($ch);
>>
>> ?>
>> I changed the value of the proxy url and proxy port to my own data.
>>
>> When i try to run the above script, it returns false on the $data. Is
>> there some special configurations to be done on the server?
>>
>> I am using PHP Version 4.4.8 and the curl installed on the server is
>> libcurl/7.16.0 OpenSSL/0.9.7m zlib/1.2.3.
>> _______________________________________________
>> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>>
>>
>
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>
>

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2008-07-01