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 应用程序
基础教程推荐
- Bootstrap 模态出现在背景下 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
