如何使用 ScriptTags 为 shopify 开发 Rails 应用程序 [英] How to develop rails app for shopify with ScriptTags

查看:20
本文介绍了如何使用 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 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆