PHP: Post JSON object to API without curl

PHOTO EMBED

Mon Aug 29 2022 19:11:35 GMT+0000 (Coordinated Universal Time)

Saved by @marcopinero #php

<?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);
?>
content_copyCOPY