[英]How do I retrieve Wix Store Products using python script. 404 error
When I run this python script on my PC I get the following error: An error occurred: 404当我在我的电脑上运行这个 python 脚本时,我收到以下错误:发生错误:404
I have created a Wix Store.我创建了一个 Wix 商店。 (Free plan).
(免费计划)。 While logged into the Wix Store, I have created API. Account Settings -> API ( https://manage.wix.com/account/api-keys )
登录到 Wix 商店时,我创建了 API。帐户设置 -> API ( https://manage.wix.com/account/api-keys )
From the account settings I have the Account ID, and the API Key, with permissions to read, write, delete, update store items.从帐户设置中,我有帐户 ID 和 API 密钥,具有读取、写入、删除、更新商店项目的权限。
I have also gone to https://dev.wix.com/ and created an app there.我还去了https://dev.wix.com/并在那里创建了一个应用程序。 This created APP provides OAUTH App ID & App Secret Key.
这个创建的APP提供OAUTH App ID & App Secret Key。
import requests
# Replace YOUR_APP_SECRET and YOUR_STORE_ID with your actual values
# Not sure which set of credentials to put here, since none worked.
app_secret = 'see_post'
store_id = 'see_post'
headers = {
'accept': 'application/json',
'x-wix-app-secret': app_secret
}
response = requests.get(f'https://api.wix.com/stores/{store_id}/products', headers=headers)
if response.status_code == 200:
products = response.json()
print(products)
else:
print('An error occurred:', response.status_code)
Things that confuse me:让我困惑的事情:
Do I need a Wix Developer account, and then create an APP, and install this app on my wix store.我需要一个Wix开发者账号,然后创建一个APP,安装这个APP到我的wix商店。 (I have already done this, just created an app, named it, nothing else, and installed it, hoping that I could use the app secret key, and my stores site ID, to retrieve the store products.)
(我已经这样做了,只是创建了一个应用程序,命名它,没有别的,并安装了它,希望我可以使用应用程序密钥和我的商店站点 ID 来检索商店产品。)
Do I use the APP ID & APP Secret Key in my script?我是否在脚本中使用 APP ID 和 APP Secret Key? Or do I use the Account ID and Account API that I created in the account of the Wix Store.
或者我是否使用我在 Wix 商店的帐户中创建的帐户 ID 和帐户 API。
Is the store id in the URL of the wix dashboard?店铺id在wix dashboard的URL里面吗? https://manage.wix.com/dashboard/23861c7e-333-333-3333-4a18d5f55da2/
https://manage.wix.com/dashboard/23861c7e-333-333-3333-4a18d5f55da2/
What I wish to accomplish, figure out how to make this script run correctly.我希望完成的是弄清楚如何使该脚本正确运行。 Then I will modify it to do the following:
然后我将修改它以执行以下操作:
Update 1: I'm now using this code as provided in the API docs.更新 1:我现在正在使用 API 文档中提供的代码。
import json
import requests
headers = {
'Content-Type': 'application/json',
'Authorization': 'token generated by https://dev.wix.com/api/rest/wix-stores/inventory/query-inventory'
}
data = {
"query": {},
"options": {}
}
response = requests.post('https://www.wixapis.com/stores/v2/inventoryItems/query', headers=headers, data=json.dumps(data))
if response.status_code == 200:
inventory_items = response.json()
print(inventory_items)
else:
print('An error occurred:', response.status_code)
However the auth token is only valid for 10 minutes.但是,授权令牌仅在 10 分钟内有效。
a.一种。 How can I regenerate this token from my python script?
如何从我的 python 脚本中重新生成此令牌? b.
b. Do I have to use these temp.
我必须使用这些温度吗? tokens?
令牌? Can't I just use the API key?
我不能只使用 API 密钥吗?
Looks to me like you're going about this the hard way.在我看来你正在努力解决这个问题。 I think a much easier approach would be to use http-functions to expose several endpoints that then use the wix-stores-backend API and the wix-data API to access your product data.
我认为更简单的方法是使用http-functions公开多个端点,然后使用wix-stores-backend API和wix-data API来访问您的产品数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.