The problem is it seems there are few resources around. Is there any library already there/ offical one / or I need to start create the API from stratch?
与您的问题的评论之一相反,Prestashop确实提供了REST服务.在文档中它是由“Web服务”引用的.
快速链接:
有一些open source API implementations可用,但没有专门用于Android / Java.您可能会发现它们可用作指南.
需要注意以下几点:
默认情况下,Web服务功能似乎已禁用.因此,为了使用它,您必须首先在后台启用它.从文档中复制:
Enabling the webservice feature
Go in the PrestaShop back-office, open the “Webservice” page under the
“Advanced Parameters” menu, and then choose “Yes” for the “Enable
PrestaShop’s webservice”. Save your change: you’re done!
与Web服务通信需要API密钥.您必须再次使用后台为您的Android应用生成一个:
Creating an access key
Open the “Webservice” page under the “Advanced
Parameters” menu, and then click the “Add New” button to access the
account configuration section. A long form appears:
Key. The API key
serves as the main identifier for the webservice account you are
creating. Click the “Generate” button to get an unique authentication
key. You can also create your own (which must be 32 characters long),
but using a generated key prevents wrong-doers from guessing your key
too easily. Using this key, you and other selected users will be able
to access the webservice.
Key description. Helps you remember who you
created that key for, what are the access rights assigned to it, etc.
The description is not public, but make sure to put all the keywords
pertaining to the user, so that you can find their key more quickly.
Status. You can disable any key at any time.
Permissions. This section
is very important, as it enables you to assign rights for each
resource you want to make available to this key. Indeed, you might
want a user to have read and write access on some resources, but only
read access on others – and no access to the more important ones. In
the list of permissions, the checkbox most on the left enables you to
define all the rights for a given resource. Likewise, the checkbox at
the top of each column enables you to give the select right (View,
Modify, etc.) to all the resources. Make sure to only select the
rights needed for the usage of that key. Do not give all the rights
for all resources to any key, keep that to yours and yours only. Shop
association. This only appears in multistore mode. It enables you to
choose which of your stores the key owner should have access to.
If
you choose to use a custom passkey instead of a generated one, make
sure it is very secure and that its rights are limited – and that it
is 32characters long!
最后,要了解API方法的概述:
Accessing the webservice from the browser
The endpoint to your store’s
webservice is located in the /api/ folder at the root of your
installation of Prestashop:
If PrestaShop is installed at the root of
your server, you can access the API here: 07004
If
PrestaShop is installed in a subfolder of your server, you can access
the API here: 07005
To access it, you
need to provide your API key when request. There is no password,
providing your API key is enough – and therefore the key should be
kept secret by the user! You can either type the API endpoint address
directly then enter your API key, or indicate your API key in the
address. Here is an example, with UCCLLQ9N2ARSHWCXLT74KUKSSK34BFKX
being the API key.
At the root of the server:
07006
In a
subfolder of the server:
07007
You can test this with any browser that supports XML. If no permission
has been set for the key, then the browser will keep asking you to
enter the key indefinitely.
结果应该看起来像这样(对于PrestaShop的1.5.4.1版本):
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
既然你提到你主要对支持Android应用程序的基本/核心功能感兴趣,我倾向于说这可能符合你的需求. 🙂