![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Confirmed User
Join Date: Apr 2004
Location: Montreal
Posts: 799
|
![]() How can I force an HTTP GET request through a proxy server with PHP ?
Right now I use this function to send my info : function myPost($URL, $script, $data){ $sock = fsockopen($URL, 80, $errno, $errstr); fputs($sock, "GET ".$script." HTTP/1.0\r\n"); fputs($sock, "Host:".$URL."\r\n"); fputs($sock, "Content-type: application/x-www-form-urlencoded\r\n"); fputs($sock, "Content-length: " . strlen($data) . "\r\n"); fputs($sock, "Accept: */*\r\n"); fputs($sock, "\r\n"); fputs($sock, "$data\r\n"); fputs($sock, "\r\n"); fclose($sock); } Thanks for any help !
__________________
I have nothing to advertise ... yet. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Confirmed User
Join Date: Apr 2004
Location: Montreal
Posts: 799
|
bump 8 char
__________________
I have nothing to advertise ... yet. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Registered User
Join Date: Sep 2002
Posts: 50
|
fputs($sock, "Host:".$URL.":8080\r\n");
Missing port ? Other than that I can't see much wrong, although I'm tired and can't think straight atm >_< |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 |
Confirmed User
Join Date: Apr 2004
Location: Montreal
Posts: 799
|
no the function is working fine but it's not going through a proxy as it is.
I guess my question should be more like how do you interact with a proxy in php. Can't find much doc on this subject ...
__________________
I have nothing to advertise ... yet. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
Now choke yourself!
Industry Role:
Join Date: Apr 2006
Posts: 12,085
|
Here, I'll save you some time. Rewrite for cURL. It'll save you many, many, many headaches.
Code:
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $requestUrl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 'timeout_in_seconds'); curl_setopt($ch, CURLOPT_PROXY, 'proxy_ip:proxy_port'); $data = curl_exec($ch); curl_close($ch);
__________________
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 |
Now choke yourself!
Industry Role:
Join Date: Apr 2006
Posts: 12,085
|
See my following answer. Writing fsock code to do posting is both deprecated, and painful. Trying to make it nest multiple levels for proxy CONNECT statements, et al, is just asinine when there already exists the functionality.
__________________
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 |
Confirmed User
Join Date: Apr 2004
Location: Montreal
Posts: 799
|
Thanks ! Does the job perfectly !
__________________
I have nothing to advertise ... yet. |
![]() |
![]() ![]() ![]() ![]() ![]() |