Webhook Receiving With PHP

Highlighted

So I've registered my app/uninstalled webhook using PHP. And its working good. I got response in requestcatcher.com.

Now i wanted to get that response in my e.g. /Delete.php file. So for that i followed first verifying webhook. But problem is i think response is not comming in a way.

 

->> Im attaching my response from requestcatcher.com.

Response from requestcatcher.comResponse from requestcatcher.com

->> Now i want to get this same response in my domain file /delete.php and also im posting my code for receiving webhook.

<?php

define('SHOPIFY_APP_SECRET', 'xxxxxxxxxxxxxxxxxxxxxx');

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

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

echo "<pre>";
print_r($verified);
exit;

?>

But its not working.!!!!

0 Likes
Highlighted
Shopify Staff
Shopify Staff
1555 81 282

While I'm not fluent in PHP - can you explain a bit more what you're expecting vs what is occurring? Are you receiving the web request in the first place? How is your server responding to it? If you're not receiving the request, what PHP web server are you using, what does your route look like? Is your app running behind a tunnel, is it hosted on a cloud service like Heroku?

 

More details are very appreciated.

 

Cheers.

1 Like
Highlighted

@Alex

Hello Im expecting the web request of webhook in my file /delete.php but its not working. I got code of verifying webhook form shopify documentation. But its not working with me.


Yes i got web request in first place https://example.requestcatcher.com. And yes it is hosted in Heroku.

 

PFA screenshot.

 

 

 

 

0 Likes
Highlighted
New Member
4 0 0

Hey Pratham

 

The json response is in the $data variable.

0 Likes
Highlighted
Excursionist
31 0 5

Hi,

Did anyone solved this? I am having the same problem, i can't retrieve the webhook data on my heroku app.

0 Likes