Skip to content

Instantly share code, notes, and snippets.

@sirleech
Created November 10, 2012 07:45
Show Gist options
  • Save sirleech/4050330 to your computer and use it in GitHub Desktop.
Save sirleech/4050330 to your computer and use it in GitHub Desktop.
PHP with Cosm and CURL
<?php
function putToCosm($csv){
echo 'logging to cosm...';
$url = 'http://api.cosm.com/v2/feeds/YOURFEEDID.csv';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, $csv);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'X-ApiKey: YOURAPIKEY'
));
$response = curl_exec($ch);
curl_close($ch);
echo $response;
}
$csv = "0,44
1,45
2,234";
echo $csv;
putToCosm($csv);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment