<?php

if(isset($_SERVER['HTTPS'])) {
	$domainurl = 'https://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/';
} else {
	$domainurl = 'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/';
}

$url = $domainurl."api.php";
$data = array(
    "create_short_url" => TRUE,
    "url" => "http://abcd.com",
    "webhook" => "https://test.com/test4.php",
);
echo curl_operations($url, $data);

function curl_operations($url, $data = NULL) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    if (!is_null($data)) {
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    }
    $response = curl_exec($ch);
    curl_close($ch);
    return $response;
}
