1
votes

I want to create a custom webhook in Shopify for Customer Login using a private app below is my code, but I'm getting the error Array ( [errors] => Array ( [topic] => Array ( [0] => Invalid topic specified. Topics allowed: app/uninstalled, carts/create, carts/update, checkouts/create, checkouts/delete, checkouts/update, checkouts/paid, collections/create, collections/delete, collections/update, customer_groups/create, customer_groups/delete, customer_groups/update, customers/create, customers/delete, customers/disable, customers/enable, customers/update, order_transactions/create, orders/cancelled, orders/create, orders/delete, orders/edited, orders/fulfilled, orders/paid, orders/partially_fulfilled, orders/updated, products/create, products/delete, products/update, refunds/create, shop/update, themes/create, themes/delete, themes/publish, themes/update, tender_transactions/create, app_purchases_one_time/update, app_subscriptions/update, variants/delete ) )

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/api/2020-01/webhooks.json', array(), array
    (
        'webhook' => array 
        (
            "topic" =>  "customers/login",
            "address" => "myappurl", 
            "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());
}

Please help it is possible to create it from the private app or not?

1
Does this answer your question? Create a webhook using API in shopifyAdam Strauss
array ( 'topic' => array ( 0 => 'Invalid topic specified. Topics allowed: app/uninstalled,jhayden
getting same errorjhayden
These is no such a topic like customers/login, these are valid topics for customer => customers/create, customers/disable, customers/enable, customers/update for more detail visit shopify.dev/docs/admin-api/rest/reference/events/webhookBhargav Kaklotara

1 Answers

1
votes

With the use of web-hook you can get data on certain event occurred on shopify store which is provided by shopify itself.

to start listening this update you need to create webhook on particular store.

But you need to chose topic from the list provided by shopify.

Shopify do not provide webhook for Customer/Login event ( or topic ).

If you want to make update your system upon login you need to create custom notification ( fully custom solution ).

for that you can do is that...

Create custom code with JS & Liquid that make update to your system when user login.

you can do this via app using App Proxy