-3

How can I send POST data using fopen() or cURL?

David Nehme
  • 21,379
  • 8
  • 78
  • 117
xtremekid
  • 9
  • 1

1 Answers1

2

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.

Simone
  • 20,302
  • 14
  • 79
  • 103
EdoDodo
  • 8,220
  • 3
  • 24
  • 30