Created
November 10, 2012 07:45
-
-
Save sirleech/4050330 to your computer and use it in GitHub Desktop.
PHP with Cosm and CURL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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