简体   繁体   English

如何使用 python 脚本检索 Wix Store Products。 404错误

[英]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:让我困惑的事情:

  1. 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 来检索商店产品。)

  2. 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。

  3. 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:然后我将修改它以执行以下操作:

  1. List列表
  2. Add/remove products添加/删除产品
  3. Change Product attributes such as price, description, etc.更改产品属性,例如价格、描述等。
  4. Sync Inventory between Wix, and a local database.在 Wix 和本地数据库之间同步库存。

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 APIwix-data API来访问您的产品数据。

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

相关问题 AWS Lambda Python 脚本。 如何返回对象并保持 scipt 在后台运行? - AWS Lambda Python script. How do I return an object and keep the scipt running in the background? 如何使用 Tkinter 在 python 脚本中存储图像? - How do I store images in a python script using Tkinter? 使用Python ssh然后运行bash脚本。 我需要在屏幕上显示正在运行的bash脚本的输出 - Using Python to ssh then run bash script. The output of the running bash script i need to display on the screen 如何使用 python 检索令牌 - How do I retrieve the token using python bash 脚本中的 Python 脚本。 如何不在控制台上打印日志错误? - Python script inside bash script. How to not print log error on console? 我如何正确使用函数调用。 我要做2批python脚本。 一个在输入中,另一个在输出中 - How do i use function call properly. I am gonna do 2 batch python script. The one is in input the other one is output SQL Python 脚本中的计数错误。 我究竟做错了什么? - SQL Count error from within Python script. What am I doing wrong? 我在shell脚本中运行程序。 我怎么知道它是否已加载? (Linux)的 - I run a program in a shell script. How do i know if it has loaded? (Linux) 如何解决 python 中的 404 Flask 错误? - How do I solve 404 Flask error in python? 如何在 urllib 中捕获 404 错误? (蟒蛇3) - How do I catch a 404 error in urllib? (python 3)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM