Skip to content

Instantly share code, notes, and snippets.

@libryder
Created February 22, 2012 17:10
Show Gist options
  • Select an option

  • Save libryder/1886121 to your computer and use it in GitHub Desktop.

Select an option

Save libryder/1886121 to your computer and use it in GitHub Desktop.
Method to post to a rest service without cURL
<?php
$data = array (
"limit" => 5,
"api_key" => 'YOUR_API_KEY',
"api_secret" => 'YOUR_API_SECRET',
);
$method = "getCallDetails";
$url = "https://api.logmycalls.com/services/$method";
$opts = array('http' =>
array(
'method' => 'POST',
'header' => "Accept: application/json\r\n" . "Content-Type: application/json\r\n",
'content' => json_encode($data)
)
);
$context = stream_context_create($opts);
$result = file_get_contents($url, false, $context);
?>
@shubhamkhuva
Copy link

Yeah it's working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment