2

我正在使用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 admin 并授予完全权限。考虑过使用 REST API,但在阅读了这个未回答的问题后,似乎遇到了同样的问题。

**

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

**

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
4

2 回答 2

0

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

于 2013-06-22T20:52:34.003 回答
0

不确定线程​​发起者是否仍然有问题,但我在 Magento 1.8 中遇到了python-magento和 xmlrpc 的问题。

from magento import *
m = MagentoAPI('mag1', 80, 'user', 'pass')

失败了

<ProtocolError for mag1:80/magento/api/xmlrpc: 404 Not Found>

python-magento 中的默认 PATH 是 /magento/api/xmlrpc。

将其更改为 '/index.php/api/xmlrpc' 对我有用:

m = MagentoAPI('mag1', 80, 'user', 'pass', path='/index.php/api/xmlrpc')

成功。

Magento 1.8 中新的重写处理导致的问题。有关更多信息,请参见此处: 访问.

希望这可以帮助。

杰瑞。

于 2013-11-18T18:26:23.670 回答