Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrating With Webhooks #2

Open
korynorthrop opened this issue Jan 30, 2015 · 0 comments
Open

Integrating With Webhooks #2

korynorthrop opened this issue Jan 30, 2015 · 0 comments

Comments

@korynorthrop
Copy link

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());
    }

?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant