2017-03-31T22:33:13
PHP HTTP JSON POST Request (Webhook)
function sendWebhook($data) {
$url = 'https://url/';
$jsonDataEncoded = json_encode($data);
$webhook = curl_init($url);
curl_setopt($webhook, CURLOPT_POST, 1);
curl_setopt($webhook, CURLOPT_POSTFIELDS, $jsonDataEncoded);
curl_setopt($webhook, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$result = curl_exec($webhook);
}
$data = array(
'key' => 'value'
);
sendWebhook($data);
Source: http://thisinterestsme.com/sending-json-via-post-php/