lundi 2 mars 2015

USING client ip address while using PHP CURL to post form data

I am trying to use curl to post data to a form and everything works very well except that when I send the form, it makes use of the server ip address in sending the form but what I really would like to do is to set a custom user agent(The reason why I need to use curl) and I need the client's ip to remain intact.


Here is the code I am using right now.



//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);

//The next line set the user agent to a custom one.

curl_setopt($ch, CURLOPT_USERAGENT, "Mobile UA :" . $rrand );
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);

//execute post
$result = curl_exec($ch);


//close connection curl_close($ch);


I want curl to use the client ip address while sending the form and not the address of the server hosting the php script. If it is possible to set custom server address to post the form, that would help as well.


Thanks.


Aucun commentaire:

Enregistrer un commentaire