sending post data using fopen or curl? [closed]
How can I send POST data using fopen() or cURL?
Here's an example that uses the PHP curl to send POST data:
<?
$ch = curl_init();
$data = array('var1' => 'Foo', 'var2' => 'Bar');
curl_setopt($ch, CURLOPT_URL, 'http://localhost/');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_exec($ch);
?>
You can find more information on curl in the PHP documentation.
精彩评论