3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $request = 'POST'; // I've set the callback url to http://signature.wix.codeoasis.com/ // I've tried with and without the '/' (ie $url = '') $url = '/'; $headers = array( 'X-Wix-Signature' => '3elavUOF0-I1_7tGz2XZKs_HSlrygsMiblpNFPKv3Ik', "X-Wix-Instance-Id" => "132fc751-9325-63d3-a605-f74e0c25192a", "X-Wix-Event-Id" => "da390885-e72f-4a93-be7f-a90220bac5c7", "X-Wix-Event-Type" => "/provision/provision", "X-Wix-Timestamp" => "2013-10-23T15:39:34.462Z", "X-Wix-Application-Id" => "132fbf95-d58e-f9ed-86e8-48b76f901d91" ); //$body = "{\n\t\"instance-id\": \"1328a7fe-e451-8780-d201-0c5d9a1fc02b\"\n}"; $body = '{"instance-id":"132fc751-9325-63d3-a605-f74e0c25192a"}'; // The app secret provided by Wix $appSecret = "97cfac6e-b061-4007-a03e-eb4bc199e620"; function concat($request, $url, $headers, $body) { // Request Method and Url separated by \n $result = trim($request); $result .= "\n"; $result .= trim($url); $result .= "\n"; // Sort Wix-* headers by key ksort($headers); // concatenate Wix-* headers (trimmed and separate by comma) $first = true; foreach ($headers as $key => $value) { if ($key != 'X-Wix-Signature' && $first == true) { $result = $result . trim($value); $first = false; } else if ($key != 'X-Wix-Signature') { $result = $result . ',' . trim($value); } } // Add body $result = $result . "\n" . trim($body); return $result; } $concat = concat($request, $url, $headers, $body); // Encrypt with hmac and app secret $encrypted = hash_hmac('sha256', $concat, $appSecret); //$base64 = base64_encode($encrypted); echo "The computed signature is : " . $encrypted . "\n"; echo "The signature sent by Wix : " . $headers['X-Wix-Signature']; echo "The concat result is : " . $concat; // The received request on http://signature.wix.codeoasis.com/ // // { // "Host": "signature.wix.codeoasis.com", // "X-Wix-Signature": "3elavUOF0-I1_7tGz2XZKs_HSlrygsMiblpNFPKv3Ik", // "X-Wix-Instance-Id": "132fc751-9325-63d3-a605-f74e0c25192a", // "X-Wix-Event-Id": "da390885-e72f-4a93-be7f-a90220bac5c7", // "Content-Type": "application/json; charset=utf-8", // "X-Wix-Event-Type": "/provision/provision", // "X-Wix-Timestamp": "2013-10-23T15:39:34.462Z", // "X-Wix-Application-Id": "132fbf95-d58e-f9ed-86e8-48b76f901d91", // "Connection": "keep-alive", // "Accept": "*/*", // "User-Agent": "Dispatch/0.10.1", // "Content-Length": "54", // "body": // { // "instance-id":"132fc751-9325-63d3-a605-f74e0c25192a" // } // }
Output for 5.1.2 - 7.1.0
The computed signature is : 9fd3090c84e3d2a5b79b2c36ff222198981e5882da667832f22d78d428dff57c The signature sent by Wix : 3elavUOF0-I1_7tGz2XZKs_HSlrygsMiblpNFPKv3IkThe concat result is : POST / 132fbf95-d58e-f9ed-86e8-48b76f901d91,da390885-e72f-4a93-be7f-a90220bac5c7,/provision/provision,132fc751-9325-63d3-a605-f74e0c25192a,2013-10-23T15:39:34.462Z {"instance-id":"132fc751-9325-63d3-a605-f74e0c25192a"}
Output for 5.0.0 - 5.0.5, 5.1.1
Fatal error: Call to undefined function hash_hmac() in /in/Fqvja on line 53
Process exited with code 255.
Output for 5.1.0
Fatal error: fatal flex scanner internal error--end of buffer missed in /in/Fqvja on line 80
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: hash_hmac() in /in/Fqvja on line 53
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: hash_hmac() in /in/Fqvja on line 53
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: hash_hmac() in /in/Fqvja on line 53