3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php// User Public/Private Keys $private_key = 'private_key_user_id_QQKsTYtABdHd'; $public_key = 'public_key_user_id_v4dkuUg5pAeV'; // Data to be submitted $my_string = array( 'action' => 'api_register', 'first_name' => ".urlencode($first_name).", 'surname' => ".urlencode($surname).", 'user_password' => ".urlencode($user_password.)", 'user_password_repeat' => ".urlencode($user_password).", 'user_name' => ".urlencode($user_name).", 'signup_channel' => ".urlencode($signup_channel)." ); echo json_encode($my_string); // Generate content verification signature $signature = base64_encode(hash_hmac('sha1', $my_string, $private_key, TRUE)); $curl = curl_init(); if ( !$curl ) { print "Failed to initalise cURL object\n"; } else { $url ='https://www.casafina.com/api/user.php'; curl_setopt($ch, CURLOPT_CUSTOMREQUEST, array("signature" => $signature, "pubKey" => $public_key)); curl_setopt($ch, CURLOPT_POSTFIELDS, $my_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($my_string)) ); if ( !curl_setopt_array( $curl, $curl_opts ) ) { print "Unable to set properties on CURL object\n"; } else { $response = curl_exec( $curl ); $responseCode = curl_getinfo( $curl, CURLINFO_HTTP_CODE ); if ( is_bool( $response ) && $response == false ) { // Failed to make HTTP request to tracking URL echo 'Error from CURL in livefeed: "', curl_error( $curl ), '" ', var_export( curl_getinfo( $curl ), TRUE ); } else if ( ! ( $responseCode >= 200 && $responseCode <= 299 ) ) { // We got an HTTP response, but it was not successful print "Error: Tracking URL returned HTTP $responseCode\n"; } else { // All good print "Success, response was:\n"; echo var_export( $response ), "\n"; } } } curl_close( $curl ); // log the values $values[] = $response; $values[] = $responseCode; $values[] = $my_string; logResults($values, 'Casafina');
Output for 5.3.0 - 5.4.32
<?php// User Public/Private Keys $private_key = 'private_key_user_id_QQKsTYtABdHd'; $public_key = 'public_key_user_id_v4dkuUg5pAeV'; // Data to be submitted $my_string = array( 'action' => 'api_register', 'first_name' => ".urlencode($first_name).", 'surname' => ".urlencode($surname).", 'user_password' => ".urlencode($user_password.)", 'user_password_repeat' => ".urlencode($user_password).", 'user_name' => ".urlencode($user_name).", 'signup_channel' => ".urlencode($signup_channel)." ); echo json_encode($my_string); // Generate content verification signature $signature = base64_encode(hash_hmac('sha1', $my_string, $private_key, TRUE)); $curl = curl_init(); if ( !$curl ) { print "Failed to initalise cURL object\n"; } else { $url ='https://www.casafina.com/api/user.php'; curl_setopt($ch, CURLOPT_CUSTOMREQUEST, array("signature" => $signature, "pubKey" => $public_key)); curl_setopt($ch, CURLOPT_POSTFIELDS, $my_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($my_string)) ); if ( !curl_setopt_array( $curl, $curl_opts ) ) { print "Unable to set properties on CURL object\n"; } else { $response = curl_exec( $curl ); $responseCode = curl_getinfo( $curl, CURLINFO_HTTP_CODE ); if ( is_bool( $response ) && $response == false ) { // Failed to make HTTP request to tracking URL echo 'Error from CURL in livefeed: "', curl_error( $curl ), '" ', var_export( curl_getinfo( $curl ), TRUE ); } else if ( ! ( $responseCode >= 200 && $responseCode <= 299 ) ) { // We got an HTTP response, but it was not successful print "Error: Tracking URL returned HTTP $responseCode\n"; } else { // All good print "Success, response was:\n"; echo var_export( $response ), "\n"; } } } curl_close( $curl ); // log the values $values[] = $response; $values[] = $responseCode; $values[] = $my_string; logResults($values, 'Casafina');