Reputation: 73
I'm trying to get a response.
Using curl_exec
works fine, but the problem is that it gets a response with different IP.
I want to get response from client or user IP, rather than server IP.
$URL = "https://drive.google.com/get_video_info?docid=".$_SERVER["QUERY_STRING"];
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $URL);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 2);
$response_data = urldecode(urldecode(curl_exec($curl)));
Upvotes: 0
Views: 840
Reputation: 21463
get the client to install curl on its own computer, and run the code there, or get the client to install a proxy on its computer, then proxy your connection through the client's with CURLOPT_PROXY & co.
Upvotes: 0
Reputation: 6091
The curl
runs on the server and not in the client. Any HTTP command issued by curl will use the server IP as the requester.
Depending on the service you are invoking, probably you can use the X-Forwarded-For
HTTP header used in the Internet Proxies.
$URL = "https://drive.google.com/get_video_info?docid=".$_SERVER["QUERY_STRING"];
$curl = curl_init();
// set the command as requested by the client IP
curl_setopt($curl,CURLOPT_HTTPHEADER,array('X-Forwarded-For: '. $_SERVER['REMOTE_ADDR']));
curl_setopt($curl, CURLOPT_URL, $URL);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 2);
$response_data = urldecode(urldecode(curl_exec($curl)));
The service you are invoking may use the header to determine the ip of the originator. Using the X-Forwarded-For
will not work with all the services and server-side frameworks.
XMLHttpRequest
or some functions in JQuery or Angular) to make the request.You may check:
X-Forwarded-For
: Get the client IP address using PHPX-Forwarded-For
with curl: How can I spoof the sender IP address using curl?Upvotes: 1