Reputation: 1
I am trying to implement the Bigcommerce webhook and I have successfullly cretead the store/product/updated* webhook. When I am trying to get the response on my destination url, I am getting nothing. I am using following code to record the response which is send by webhook to my url. My code is
<?php
$webhook_content = '';
$webhook = fopen('php://input' , 'rb');
while(!feof($webhook)){ //loop through the input stream while the end of file is not reached
$webhook_content .= fread($webhook, 4096); //append the content on the current iteration
}
fclose($webhook); //close the resource
$data=$webhook_content;
$data = json_decode($webhook_content,true); //convert the json to array
$myfile = __DIR__.'/productupdatelog.txt';
file_put_contents($myfile, print_r($data,true));
?>
But still I am not getting anything. Bigcommerce team is saying that Checking out that destination URL we do appear to be sending you webhooks and properly receiving back a 200 response from your server. But I am not able too record anything.
Upvotes: 0
Views: 691
Reputation: 59
you can get it using file_get_content and store the response to file or database. you will get json encoded response within next 1 min.
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$webhookContent = file_get_contents("php://input");
$result = json_decode($webhookContent, true);
}
for more details : https://developer.bigcommerce.com/api/#respond-to-webhook-callbacks
Upvotes: 1
Reputation: 2058
you can use file_get_contents and error_log to see the data:
$webhookContent = file_get_contents("php://input");
error_log($webhookContent);
Upvotes: 0