PHP: Post JSON object to API 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); ?>
Non tested

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.