Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Need help in Shopify Webhooks/callback url

Need help in Shopify Webhooks/callback url

mo_zap
Shopify Partner
18 0 0

 

Building new shopify app using Rails framework.

I am very new to Shopify and webhooks also. First I tried webhooks in API level and ended up with no proper documentation or I dint understand properly.

So I am planning to implement the Shopify default webhooks which is in Shopify Admin page -> Settings -> Notification page bottom.

I have create a Webhooks for 'Order Creation' by giving the call back url and it is working fine. When ever new order is placed my callback url is getting called and I am able to perform my custom tasks (whatever in the file) call back url ex : http://example.com/webhooks/API.php

here I am facing 2 problem

When ever the order is creating API.php is calling properly, But calling more than one time. means It is keep calling . note: I closed the webhooks after getting the required information, But still webhooks connections is getting closed/deleted.

I have given call back URL in the Shopify admin page manually, ex: going to webhooks admin page and selecting the Event 'order Create' and provide the my API callback URL. I dont want all users has to go through this process and configure It manually, since it is not good.

I want this to be create automatically once my App is installed for the Shop .

Please some one please suggest me how can I do it.

I am Ok with API level Webhooks implementation also If some one can help me.

THanks.

 

Replies 5 (5)

Nate19
Shopify Staff (Retired)
97 0 8

Webhooks can be created automatically once your app is installed using the Webhook API, see:

http://docs.shopify.com/api/webhook#create

Is your other problem that too many Webhooks are being delivered for a single order creation?

To learn more visit the Shopify Help Center or the Community Blog.

mo_zap
Shopify Partner
18 0 0

Thanks for quick replay.

1st problem is I am not able to figure it out how to use the Webhooks in API level, I am very new to this and looking for little assistance or documents or tutorials from the scratch. 

2nd issue is this is my call back url ex : http://example.com/webhooks/API.php, when I create order I have to send an SMS and It is working fine. But It is sending message again and again, that means webhooks is not closing or something is wrong.

This is what I used in my API file 

$webhookContent = "";

$webhook = fopen('php://input' , 'rb');

while (!feof($webhook)) {

    $webhookContent .= fread($webhook, 4096);

}

fclose($webhook); --> Here I am closing the Webhook, But don't know why is it calling more than once.

 

 

 

 

 

 

Nate19
Shopify Staff (Retired)
97 0 8

In addition to the Webhook reference documentation that I linked to in my first post, here is an Introduction to Webhooks:

http://docs.shopify.com/api/webhooks/using-webhooks

Could you log the Request-Id header of the Webhooks you are receiving and paste some of them here?

To learn more visit the Shopify Help Center or the Community Blog.

mo_zap
Shopify Partner
18 0 0

i have been most of the links and read about Webhooks, but none of them are helpful for me :(. FYI: I am working Rails framework to develop the app

can you please be more specific , I am not sure what exactly you are asking.

Thanks

 

akash_malik
Shopify Partner
2 0 0

Mo Zap , i also have same issue. didu have any solution found plz help me out too