问题描述
我在Heroku中部署了一个shopify应用程序,用Rails开发。
我需要从任何shopify商店的前端调用javascript函数。
我读过这篇文章(),但我不明白......
I have a shopify app deployed in Heroku, developed in Rails. I need call a javascript function from any shopify store's frontend.I've read this article ( http://www.shopify.com/technology/3033852-shopify-api-update-scripttags-javascript-insertion ), but I don't understand it...
我在哪里放这个代码:
HTTP POST http://their-shop.myshopify.com/admin/scripttags
<?xml version="1.0" encoding="UTF-8"?>
<script-tag>
<src>http://example.com/your-awesome-script.js</src>
<event>onload</event>
</script-tag>
src标签应该是什么(对于我部署的rails app),
以及应该在哪里我把javascript调用函数?
What should be the src tag (for my deployed rails app),and where should I put the javascript call function?
推荐答案
这可能会有所帮助。
您只需要对用户进行身份验证,然后您需要获取Shopify生成的令牌并将其保存在您的数据库中。
稍后再做:
You simply need to authenticate user and then you need to take the token generated from Shopify and save it in your Database. Later on just do:
ShopifyAPI::Base.site = token
然后使用以下命令安装脚本:
and then install the script using:
s = ShopifyAPI::ScriptTag.create(:events => "onload",:src => "your javascript url")
你完成了!
这篇关于如何使用ScriptTags为shopify开发rails app的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!