Topics covering webhook creation & management, event handling, Pub/Sub, and Eventbridge, in Shopify apps.
I have logged in browser with shopify credentials, when I hit the "admin/webhooks.json" API in browser I am getting the response array with webhook details but If I tried to do CURL Get request using PHP code it is giving me a blank array response.
Here is the code.
$webhooks_url = $shopify_api_url."/admin/webhooks.json";
$webhooks = curlRequest(array(),$webhooks_url,false);
/* Function to make curl request for Shopify */
function curlRequest($auth_header,$request_api,$is_post,$data=null,$is_delete=false){
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $auth_header);
curl_setopt($ch, CURLOPT_URL, $request_api);
if($is_post == true){
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$output = curl_exec($ch);
curl_close($ch);
$output = json_decode($output, true);
return $output;
}
This is the Output Logged
development.ERROR: Array
(
[webhooks] => Array
(
)
)
Solved! Go to the solution
This is an accepted solution.
Hey there,
As documented here, webhooks are scoped only to the app that they're registered to. So when you are making the call in the admin, you will see all of the webhook notifications which you set up in the admin.
When you make the same call to the "/admin/webhooks.json" endpoint using your API credentials, you will only see the webhooks which you registered with that API client. In your case, you must not have any webhooks which were registered with your app, which is why the response is an empty array.
To learn more visit the Shopify Help Center or the Community Blog.
This is an accepted solution.
Hey there,
As documented here, webhooks are scoped only to the app that they're registered to. So when you are making the call in the admin, you will see all of the webhook notifications which you set up in the admin.
When you make the same call to the "/admin/webhooks.json" endpoint using your API credentials, you will only see the webhooks which you registered with that API client. In your case, you must not have any webhooks which were registered with your app, which is why the response is an empty array.
To learn more visit the Shopify Help Center or the Community Blog.