Skip to content

Instantly share code, notes, and snippets.

@davidvanvickle
Created September 22, 2011 02:40
Show Gist options
  • Save davidvanvickle/1233901 to your computer and use it in GitHub Desktop.
Save davidvanvickle/1233901 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