3v4l.org

run code in 300+ PHP versions simultaneously
<?php $url = "https://101@dev.ewingirrigation.com/rest/"; $api_key = 'gSJ5^sVWAWb=L#HAyVXd^WK+_WpX2kew'; $ts = time(); $salt = substr($ts,0,-2); $hash = hash("sha256", $api_key.$salt); $postfields = Array( 'hash' => $hash, 'ts' => $ts ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, utf8_encode(json_encode($postfields))); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded')); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_VERBOSE, true); curl_setopt($ch, CURLOPT_COOKIEJAR, '/tmp'); $response = curl_exec($ch) or die('no curl '.curl_error($ch)); $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE); $header = substr($response, 0, $header_size); $body = substr($response, $header_size); echo "<pre>"; echo $header; echo "<hr>"; print_r($body);

preferences:
34.74 ms | 402 KiB | 5 Q