Sending Post via cURL (cmd line and PHP)

By Tom / August, 3, 2009 / 0 comments

To send via the command line and output to a text file.

curl <destIpAddress>/en/set_setupE.cgi -d ipaddr_enc=10.161.0.34 -o test.txt

To run the same command in php.

function post ( $scrIpAddress , $destIpAddress) {
 $ch = curl_init();

 curl_setopt($ch, CURLOPT_URL,"$destIpAddress/en/set_setupE.cgi");
 curl_setopt($ch, CURLOPT_POST, 1);
 curl_setopt($ch, CURLOPT_POSTFIELDS, "ipaddr_enc=$scrIpAddress");

 curl_exec ($ch);
 curl_close ($ch);
}