Skip to content

Instantly share code, notes, and snippets.

@sandeepshetty
Created February 15, 2012 20:32

Revisions

  1. sandeepshetty revised this gist Feb 15, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.aw
    Original file line number Diff line number Diff line change
    @@ -12,6 +12,6 @@ function verify_webhook($data, $hmac_header)
    $hmac_header = $_SERVER['HTTP_X_SHOPIFY_HMAC_SHA256'];
    $data = file_get_contents('php://input');
    $verified = verify_webhook($data, $hmac_header);
    error_log("Webhook verified: ".var_export($verified, true)); //check error.log to see the result
    error_log('Webhook verified: '.var_export($verified, true)); //check error.log to see the result

    ?>
  2. sandeepshetty revised this gist Feb 15, 2012. 1 changed file with 7 additions and 3 deletions.
    10 changes: 7 additions & 3 deletions gistfile1.aw
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,17 @@
    <?php

    $hmac_header = $_SERVER['HTTP_X_SHOPIFY_HMAC_SHA256'];
    $data = file_get_contents('php://input');
    $verified = verify_webhook($data, $hmac_header);
    define('SHOPIFY_APP_SECRET', 'my_shared_secret');

    function verify_webhook($data, $hmac_header)
    {
    $calculated_hmac = base64_encode(hash_hmac('sha256', $data, SHOPIFY_APP_SECRET, true));
    return ($hmac_header == $calculated_hmac);
    }


    $hmac_header = $_SERVER['HTTP_X_SHOPIFY_HMAC_SHA256'];
    $data = file_get_contents('php://input');
    $verified = verify_webhook($data, $hmac_header);
    error_log("Webhook verified: ".var_export($verified, true)); //check error.log to see the result

    ?>
  3. sandeepshetty created this gist Feb 15, 2012.
    13 changes: 13 additions & 0 deletions gistfile1.aw
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    <?php

    $hmac_header = $_SERVER['HTTP_X_SHOPIFY_HMAC_SHA256'];
    $data = file_get_contents('php://input');
    $verified = verify_webhook($data, $hmac_header);

    function verify_webhook($data, $hmac_header)
    {
    $calculated_hmac = base64_encode(hash_hmac('sha256', $data, SHOPIFY_APP_SECRET, true));
    return ($hmac_header == $calculated_hmac);
    }

    ?>