gpt4 book ai didi

php - Python 2.7、Magento Community 1.8 API 连接问题

转载 作者:可可西里 更新时间:2023-11-01 10:47:29 27 4
gpt4 key购买 nike

我正在使用 python-magento API运气不好建立联系。此 API 试图使用 Magento 的 XML-RPC以及与 Community Magento 1.8 的连接...

我的本​​地安装是 Windows 8 上的 Python 2.7 (64),而 Magento 是在 PHP 5.4 堆栈上。

经过一些改动并使用了一些 API,这是 python-magento API 的主要错误,尝试从 Pycharm 和 DataNitro 连接...

Traceback (most recent call last):
File "C:/Users/xxx/Documents/PYTHON/magento_test_connect.py", line 2, in <module>
magento = MagentoAPI("xxx.com", 80, "userxxx", "passxxx")
File "C:\Python27\lib\site-packages\magento\__init__.py", line 20, in __init__
self.login()
File "C:\Python27\lib\site-packages\magento\__init__.py", line 59, in login
self._session_id = self._client.login(self._api_user, self._api_key)
File "C:\Python27\lib\xmlrpclib.py", line 1224, in __call__
return self.__send(self.__name, args)
File "C:\Python27\lib\xmlrpclib.py", line 1578, in __request
verbose=self.__verbose
File "C:\Python27\lib\xmlrpclib.py", line 1264, in request
return self.single_request(host, handler, request_body, verbose)
File "C:\Python27\lib\xmlrpclib.py", line 1297, in single_request
return self.parse_response(response)
File "C:\Python27\lib\xmlrpclib.py", line 1473, in parse_response
return u.close()
File "C:\Python27\lib\xmlrpclib.py", line 793, in close
raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault 2: 'Access denied.'>

Process finished with exit code 1

我一直在寻找一些方向,但现在我要悬赏,因为我发现网络上没有很好地记录使用 Python 连接到 Magento。

我缩小到的代码是...

from magento import *
magento = MagentoAPI("xxx.com", 80, "userxxx", "passxxx")
magento.help() #just to see some results

转到直接 url 路径(检查防火墙问题),我得到...

<methodResponse><fault><value><struct><member><name>faultCode</name><value><int>630</int></value></member><member><name>faultString</name><value><string>Unable to read request</string></value></member></struct></value></fault></methodResponse>

我已将所有详细信息输入 Magento 管理员并授予全部权限。考虑过使用 REST API,但在阅读此 unanswered question 之后,看起来有同样的问题。

**

稍微修改一下我的代码...

**

import magento
url = 'xxx.com'
port = 8080
apiuser = 'userxxx'
apipass = 'passxxx'

with magento.MagentoAPI(url, port, apiuser, apipass) as product_api:
order_filter = {'created_at':{'from':'2013-01-15 00:00:00'}}
products = product_api.list(order_filter)

错误...

socket.error: [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

我能够在另一个 Magento 安装上进行设置并且它有效,显示...

Resources:

cart: create, info, license, order, totals
cart_coupon: add, remove
cart_customer: addresses, set
cart_payment: list, method
cart_product: add, list, moveToCustomerQuote, remove, update
cart_shipping: list, method
catalog_category: assignProduct, assignedProducts, create, currentStore, delete, info, level, move, removeProduct, tree, update, updateProduct
catalog_category_attribute: currentStore, list, options
catalog_product: create, currentStore, delete, getSpecialPrice, info, list, listOfAdditionalAttributes, setSpecialPrice, update
catalog_product_attribute: addOption, create, currentStore, info, list, options, remove, removeOption, types, update
catalog_product_attribute_media: create, currentStore, info, list, remove, types, update
catalog_product_attribute_set: attributeAdd, attributeRemove, create, groupAdd, groupRemove, groupRename, list, remove
catalog_product_attribute_tier_price: info, update
catalog_product_custom_option: add, info, list, remove, types, update
catalog_product_custom_option_value: add, info, list, remove, update
catalog_product_downloadable_link: add, list, remove
catalog_product_link: assign, attributes, list, remove, types, update
catalog_product_tag: add, info, list, remove, update
catalog_product_type: list
cataloginventory_stock_item: list, update
core_magento: info
core_store: info, list
customer: create, delete, info, list, update
customer_address: create, delete, info, list, update
customer_group: list
directory_country: list
directory_region: list
giftmessage: setForQuote, setForQuoteItem, setForQuoteProduct
sales_order: addComment, cancel, hold, info, list, unhold
sales_order_creditmemo: addComment, cancel, create, info, list
sales_order_invoice: addComment, cancel, capture, create, info, list, void
sales_order_shipment: addComment, addTrack, create, getCarriers, info, list, removeTrack, sendInfo

Process finished with exit code 0

最佳答案

经过多次测试,1.7 安装成功,而 1.8 在同一服务器和配置上仍处于阻塞状态。唯一的结论是 1.8 未完成 API 使用,此问题(截至 2013 年 6 月 23 日)是 1.8 Magento 错误。

关于php - Python 2.7、Magento Community 1.8 API 连接问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17139465/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com