Это может быть то, что вы ищете:
$data = [
'service' => 'login',
'username' => 'demo',
'password' => 'demo',
'appId' => '156'
];
$postData = json_encode($data); //create json
$ch = curl_init('http://demo.oncloud.gr/s1services?login'); //initialize curl
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); //attach json
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
$result = curl_exec($ch); //send and fetch result
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); //get http code
curl_close($ch);
if($httpcode === 200) {
echo '<p>' . $result . '</p>'; //print the result
}