Warnung: file_put_contents(/home/www/web1/html/php_dev/test.txt) [function.file-put-contents]: failed to open stream: Permission denied in /home/www/web1/html/php_dev/sys/lib.activity.php (Zeile 58)
CURL & Proxy [Archiv] - PHP-Scripte PHP-Tutorials PHP-Jobs und vieles mehr

- Ad -
php-resource




Archiv verlassen und diese Seite im Standarddesign anzeigen :
CURL & Proxy


 
JamesCarter
27-06-2008, 03:30 
 
Hallo,

Ich habe gesehen das mann CURL auch über ein Proxy benutzen kann
allerdings kriege ich das nicht so ganz hin ich krieg entweder eine weiße Seite zurück, bzw den Fehler
HTTP/1.1 302 Found Date: Fri, 27 Jun 2008 01:21:14 GMT Server: Apache X-powered-by: PHP/5.2.6

Location:

http://www.000webhost.com/admin-review

Content-length: 0
Connection: close Content-type: text/html


oder
500 Internal Server Error
An internal server error occurred. Please try again later.




Das Script sieht wie folgt aus:

$url='http://jamescarter.web44.net/test.php';
$proxy='198.151.38.68:80';
$vars='var1=1&var2=text';

$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookiefile");
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookiefile");
curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
$result = curl_exec($ch); // run the whole process
echo "$result";
je nachdem ob ich

curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1); auf 1 oder 0 stelle

 
TobiaZ
27-06-2008, 10:46 
 
Also den Location-Header würde ich jetzt nicht wirklich als Fehler werten. Warst nicht du der jenige, dem das FOLLOW untersagt ist?

 
JamesCarter
27-06-2008, 12:16 
 
Ist mitlerweile ein anderer Webspace nun müsste es gehen :)


Alle Zeitangaben in WEZ +2. Es ist jetzt 21:06 Uhr.