How to develop rails app for shopify with ScriptTags(如何使用 ScriptTags 为 shopify 开发 Rails 应用程序)
问题描述
我在 Heroku 中部署了一个使用 Rails 开发的 shopify 应用程序.我需要从任何 shopify 商店的前端调用一个 javascript 函数.我读过这篇文章(http://www.shopify.com/technology/3033852-shopify-api-update-scripttags-javascript-insertion),但我不明白......
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...
我必须把这段代码放在哪里:
Where do I have to put this code:
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 应用程序),我应该把javascript调用函数放在哪里?
What should be the src tag (for my deployed rails app), and where should I put the javascript call function?
推荐答案
这可能会有所帮助.
Shopify Rails 应用程序
您只需对用户进行身份验证,然后您需要获取从 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 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用 ScriptTags 为 shopify 开发 Rails 应用程序


基础教程推荐
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01