我正在尝试通过基于标签的过滤来从 Shopify 获取产品。标签将是动态的,不止一个,并且会发生变化。
import json
import time
import requests
API_KEY = 'xxxx'
PASSWORD = 'xxxx'
SHOP_NAME = 'xxxx'
API_VERSION = '2020-04' #change to the API version
shop_url = "https://%s:%s@%s.myshopify.com/admin/api/%s" % (API_KEY, PASSWORD, SHOP_NAME, API_VERSION)
def callShopifyGraphQL(GraphQLString, data):
headers = {
"X-Shopify-Storefront-Access-Token": 'xxxxxx',
"accept":"application/json"
}
response = requests.post(shop_url+'/graphql', json={'query': GraphQLString, 'variables': data}, headers=headers)
answer = json.loads(response.text)
return answer['data']
str1 = '0-12'
str2 = 'physical'
graphQLquery7 = """ {
products(first:100, query:"tag:$tags") {
edges {
node {
id
tags
title
onlineStoreUrl
}
} …
Run Code Online (Sandbox Code Playgroud)