forked from notmaintained/shopify_api
-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Description
As requested from the Shopify forum, I'm seeking help in integrating this Shopify API with Webhooks. I created a Private App for my store and built a Customer Creation API call using this code. I thought I'd point the Webhook to a public URL on my personal domain (http://korynorthrop.com), but aside from that I don't understand how to get it all working. How do I get this Webhook to be recognized by my store so that when a new customer is created it will send a response to the public URL declared in the script?
<?
session_start();
require __DIR__.'/vendor/autoload.php';
use phpish\shopify;
require __DIR__.'/conf.php';
$shopify = shopify\client(SHOPIFY_SHOP, SHOPIFY_APP_API_KEY, SHOPIFY_APP_PASSWORD, true);
try
{
# Making an API request can throw an exception
$customers = $shopify('POST /admin/webhooks.json', array(), array
(
'webook' => array
(
"topic": "customers/create",
"address": "http://korynorthrop.com/path/to/public/handler",
"format": "json"
)
));
print_r($customers);
}
catch (shopify\ApiException $e)
{
# HTTP status code was >= 400 or response contained the key 'errors'
echo $e;
print_R($e->getRequest());
print_R($e->getResponse());
}
catch (shopify\CurlException $e)
{
# cURL error
echo $e;
print_R($e->getRequest());
print_R($e->getResponse());
}
?>Metadata
Metadata
Assignees
Labels
No labels