Skip to content

Instantly share code, notes, and snippets.

@esperanca
Created April 6, 2011 17:22
Show Gist options
  • Save esperanca/906088 to your computer and use it in GitHub Desktop.
Save esperanca/906088 to your computer and use it in GitHub Desktop.
<?php
// PHP example
// create a new cURL resource
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "https://demo.socialcast.com/api/messages.xml");
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, "message[title]=trying%20out%20the%20api&message[body]=hello");
curl_setopt($ch, CURLOPT_USERPWD, "emily@socialcast.com:demo");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
// grab URL and pass it to the browser
$api_return = curl_exec($ch);
echo $api_return;
// close cURL resource, and free up system resources
curl_close($ch);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment