Skip to content

Integrating With Webhooks #2

@korynorthrop

Description

@korynorthrop

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions