简体   繁体   English

Shopify博客页面中的动态数据

[英]Dynamic Data in Shopify Blog Page

I want to write an API, ie hosted at www.api.mywebsite.com (not affiliated with Shopify) and then have a shopify blog post that queries that API and displays that data using javascript. 我想写一个API,即托管在www.api.mywebsite.com(不隶属于Shopify),然后有一个shopify博客文章,查询该API并使用javascript显示该数据。

I know how to do the API potion, but can I and if so how do I do the second part where I use JS to query and display data? 我知道怎么做API药水,但我可以,如果是这样,我怎么做第二部分,我用JS来查询和显示数据?

Simple! 简单! Add an App Proxy to your App. 将App Proxy添加到您的应用程序。 With that, you setup an end point to call in your App. 有了这个,你设置一个终点来调用你的应用程序。 On the blog page you can send an Ajax GET with an ID to your App, which can then get dynamic content ready for you to use. 在博客页面上,您可以向您的应用程序发送带有ID的Ajax GET,然后可以为您提供动态内容供您使用。 You can either format the response as Liquid or as JSON as two examples. 您可以将响应格式设置为Liquid或JSON作为两个示例。 Send back Liquid, and Shopify renders it for you. 发送回Liquid,Shopify为您呈现。 Send back JSON and you can stamp out your data in a template. 发送回JSON,您可以在模板中标记数据。

And best of all it is a secure callback to your App that you know came from Shopify, so you have no hassles or security problems. 最重要的是,它是您知道来自Shopify的应用程序的安全回调,因此您没有麻烦或安全问题。 Look in your App for Extensions, and enable Online Store, where you can tinker with the Proxy. 查看您的App for Extensions,并启用在线商店,您可以在其中修改代理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM