Skip to content

Instantly share code, notes, and snippets.

@6ui11em
Forked from davidvanvickle/php-curl-post.php
Created March 8, 2012 07:55
Show Gist options
  • Save 6ui11em/1999528 to your computer and use it in GitHub Desktop.
Save 6ui11em/1999528 to your computer and use it in GitHub Desktop.
PHP: Curl post and write to file
$ch = curl_init($post_url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array('data1'=>'val','data2'=>'val2')));
$data_str = curl_exec($ch);
curl_close($ch);
file_put_contents($path_to_xml_data,$data_str);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment