donglun1918 2017-01-25 04:43
浏览 24
已采纳

Shopify使用可在浏览器上使用但无法使用golang脚本的get请求将商品添加到购物车

I wanted to automate the process of adding items to cart on shopify stores. For example, at http://www.oneness287.com . If you wish to buy these size 7.5 , going to http://oneness287-2.myshopify.com/cart/29741797961:1 automatically adds the product to my cart and redirects me to the checkout page.

But when I do

http.Get("http://oneness287-2.myshopify.com/cart/29741797961:1")

from my golang code, and then check my cart. The cart is still empty. What is different in this case? In the first case I am making the request from the browser, in the second my script is making the request. How do I fix it?

  • 写回答

1条回答 默认 最新

  • douzhuan0309 2017-01-25 06:09
    关注

    When you make the request from go code the server creates a new session (basically new cookie) whereas the browser request have its own session, hence the request are not operating on the same cart. If you really want to do this then in the go code you will have to send all the cookies that you have in browser for this particular domain.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?