如何prestashop与Android集成? [英] How to integrate prestashop with android?

查看:212
本文介绍了如何prestashop与Android集成?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我一直在使用prestashop创建了一个网上商店网站

的https://www.$p$pstashop.com/en/

和,因为我将要构建的Andr​​oid应用它。什么应用程序,包括只是一些基本功能

例如。建立客户账户/列表产品/订单的产品/薪酬/查看订单etc..common功能商铺...

的问题是似乎有大约资源很少。是否有任何图书馆已经在那里/官方单/或我要开始创建stratch的API?

阅读
HTTP://doc.$p$pstashop.com/display/PS16/Developer +指南一段时间,但不知道什么,我需要启动为止。

这是很抽象的问题,但既然社会是不那么受欢迎和资源的限制,我希望这可以从对方的经验中学习,并帮助任何其他有同样的要求。

感谢很多帮助。


解决方案

  

问题是,它似乎还有周围的一些资源。是否有任何图书馆已经在那里/官方单/或我要开始创建stratch的API?


在此相反的意见,一个在你的问题,prestashop的确实的实际上提供了一个REST服务。在文档是它提到了网络服务。

快速链接:

有几<一href=\"http://doc.$p$pstashop.com/display/PS16/Using+the+$p$pstaShop+Web+Service#Usingthe$p$pstaShopWebService-Implementations\"相对=nofollow> 的开源API实现,但没有专门针对Android / Java的。您可能会发现它们非常有用,就像一个准则。

有几件事情要注意的:

似乎在默认情况下禁用Web服务功能。因此,为了使用它,你必须先在后台启用它。从文档复制:


  

启用Web服务功能


  
  

转到在prestaShop后台,打开下的web服务页面
  高级参数菜单,然后选择是,为启用
  。prestaShop的webservice的保存更改!你就大功告成了。


与Web服务通信需要一个API密钥。你必须产生一个为你的Andr​​oid应用程序,再次使用后台:


  

创建访问键


  
  

下的高级打开web服务页面
  参数菜单,然后点击新增按钮进入
  帐户配置部分。出现一个长型:


  
  

      
  • 即可。 API密钥
      作为你的web服务帐户的主要标识
      创造。点击生成按钮,得到一个唯一的身份验证
      键。您也可以创建自己的(必须是32个字符长)
      但使用生成的密钥prevents错误的实干家从猜测你的密钥
      太容易了。使用此键,您和其他选定的用户将能
      访问web服务。

  •   
  • 键说明即可。可以帮助你记住你谁
      创建密钥,什么是分配给它的访问权限等。
      该说明是不公开的,但要确保把所有的关键字
      有关用户,这样就可以更快地找到他们的关键。


  •   
  • 状态。您可以随时禁用任意键。


  •   
  • 权限即可。本节
      是非常重要的,因为它使您能够分配每个版权所有
      资源要提供给此键。事实上,你可能
      希望用户具有读取和写入某些资源的访问,但只
      阅读其他用户的访问 - 以及更重要的进不去。在
      权限列表,最左边的复选框可用于
      定义用于给定资源的所有权利。同样,在复选框
      每列的顶部,可以给选择权(查看,
      修改等)的所有资​​源。确保只选择
      需要该密钥的使用权。不要给所有的权利
      所有资源的任何按键,请保留到你和你的唯一。店
      协会。这仅出现在MultiStore的模式。它使您能够
      选择哪个您商店的密钥所有者应该有机会获得。

  •   

  
  

如果
  您选择使用自定义密钥,而不是生成的一个,使
  确保它是非常安全的,而且其权利是有限的 - 并且它
  是32characters长!


最后,得到的API方法的概述:


  

从浏览器在访问webservice


  
  

端点您的商店的
  Web服务是位于 / API / 文件夹的根目录的
  安装prestashop的:


  
  
  
  

要访问它,你
  需要提供您的API时,密钥请求。没有密码,
  提供您的API密钥就足够了 - 因此重点应该是
  保密的用户!您可以键入API端点地址
  直接然后输入你的API密钥,或说明在你的API密钥
  地址。下面是一个例子,用 UCCLLQ9N2ARSHWCXLT74KUKSSK34BFKX
  作为API密钥。


  
  
  
  

您可以使用支持XML的任何浏览器进行测试。如果没有权限
  已设置为重点,那么浏览器就会不断地问你
  无限期输入密钥。


结果应该看起来有点像这样(为prestaShop的1.5.4.1版本):

 &LT;?XML版本=1.0编码=UTF-8&GT?;
&LT; prestashop的xmlns:XLink的=htt​​p://www.w3.org/1999/xlink&GT;
  &LT; API shop_name =MYSHOP&GT;
    &LT;地址&GT; ...&LT; /地址&GT;
    &LT;运营商&GT; ...&LT; /运营商&GT;
    &LT; cart_rules&GT; ...&LT; / cart_rules&GT;
    &LT;&推车GT; ...&LT; /车&GT;
    &LT;类别和GT; ...&LT; /类别和GT;
    &LT;&组合GT; ...&LT; /组合&GT;
    &LT;配置&GT; ...&LT; /配置&GT;
    &LT;联系人和GT; ...&LT; /触点&GT;
    &LT; content_management_system&GT; ...&LT; / content_management_system&GT;
    &LT;国家和GT; ...&LT; /国家和GT;
    &LT;货币&GT; ...&LT; /货币&GT;
    &LT; customer_messages&GT; ...&LT; / customer_messages&GT;
    &LT; customer_threads&GT; ...&LT; / customer_threads&GT;
    &LT;客户&GT; ...&LT; /客户&GT;
    &LT;&交货GT; ...&LT; /交付&GT;
    &LT;员工&GT; ...&LT; /员工&GT;
    &LT;&群体GT; ...&LT; /组&GT;
    &LT;房客与GT; ...&LT; /房客与GT;
    &LT; image_types&GT; ...&LT; / image_types&GT;
    &LT;图像及GT; ...&LT; /图片&GT;
    &LT;语言&GT; ...&LT; /语言&GT;
    &LT;厂家&GT; ...&LT; /厂家&GT;
    &LT; order_carriers&GT; ...&LT; / order_carriers&GT;
    &LT;&ORDER_DETAILS GT; ...&LT; / ORDER_DETAILS&GT;
    &LT; order_discounts&GT; ...&LT; / order_discounts&GT;
    &LT; order_histories&GT; ...&LT; / order_histories&GT;
    &LT; order_invoices&GT; ...&LT; / order_invoices&GT;
    &LT; order_payments&GT; ...&LT; / order_payments&GT;
    &LT; order_states&GT; ...&LT; / order_states&GT;
    &LT;订单&gt; ...&LT; /订单&gt;
    &LT; price_ranges&GT; ...&LT; / price_ranges&GT;
    &LT; product_feature_values​​&GT; ...&LT; / product_feature_values​​&GT;
    &LT; product_features&GT; ...&LT; / product_features&GT;
    &LT; product_option_values​​&GT; ...&LT; / product_option_values​​&GT;
    &LT; product_options&GT; ...&LT; / product_options&GT;
    &LT; product_suppliers&GT; ...&LT; / product_suppliers&GT;
    &LT;产品&GT; ...&LT; /产品&GT;
    &LT;搜索和GT; ...&LT; /搜索&GT;
    &LT; shop_groups&GT; ...&LT; / shop_groups&GT;
    &LT;商店&GT; ...&LT; /商店和GT;
    &LT; specific_price_rules&GT; ...&LT; / specific_price_rules&GT;
    &LT; specific_prices&GT; ...&LT; / specific_prices&GT;
    &LT;&国家GT; ...&LT; /状态&GT;
    &LT; stock_availables&GT; ...&LT; / stock_availables&GT;
    &LT; stock_movement_reasons&GT; ...&LT; / stock_movement_reasons&GT;
    &LT; stock_movements&GT; ...&LT; / stock_movements&GT;
    &LT;股票和GT; ...&LT; /股&GT;
    &LT;&门店GT; ...&LT; /存储&GT;
    &LT;供应商&GT; ...&LT; /供应商&GT;
    &LT; supply_order_details&GT; ...&LT; / supply_order_details&GT;
    &LT; supply_order_histories&GT; ...&LT; / supply_order_histories&GT;
    &LT; supply_order_receipt_histories&GT; ...&LT; / supply_order_receipt_histories&GT;
    &LT; supply_order_states&GT; ...&LT; / supply_order_states&GT;
    &LT; supply_orders&GT; ...&LT; / supply_orders&GT;
    &LT;标记&GT; ...&LT; /标签&GT;
    &LT; tax_rule_groups&GT; ...&LT; / tax_rule_groups&GT;
    &LT; tax_rules&GT; ...&LT; / tax_rules&GT;
    &LT;税费和GT; ...&LT; /税费和GT;
    &LT; translated_configurations&GT; ...&LT; / translated_configurations&GT;
    &LT; warehouse_product_locations&GT; ...&LT; / warehouse_product_locations&GT;
    &LT;&仓库GT; ...&LT; /仓库&GT;
    &LT; weight_ranges&GT; ...&LT; / weight_ranges&GT;
    &LT;&区GT; ...&LT; /区&GT;
  &LT; / API&GT;
  &LT; API shop_name =MYOTHERSHOP&GT; ...&LT; / API&GT;
  &LT; API shop_name =YETANOTHERSHOP&GT; ...&LT; / API&GT;
&LT; / prestashop&GT;

既然你提到你的主要目标是在Android的应用支持基本/核心功能,我倾向于说,这可能是适合您的需求。 :)

Recently I have created a eshop website using prestashop

https://www.prestashop.com/en/

And since I am going to build the android app for it. What includes in apps are only some basic function

e.g. create customer account / list product / order product / pay / view order etc..common eshop functions...

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?

read http://doc.prestashop.com/display/PS16/Developer+Guide for a while but no clue what I need to start with so far.

This is quite abstract problem but since the community is not so popular and the resource is limit I hope this can learn from the other's experience and help any others with the same request.

Thanks a lot for helping

解决方案

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?

In contrast to one of the comments on your question, Prestashop does actually offer a REST service. In the documentation is it referred to by "web service".

Quick links:

There are a few open source API implementations available, but none specifically for Android/Java. You may find them useful as a guideline though.

A few things to take note of:

The web service feature appears to be disabled by default. So in order to use it, you'll have to enable it first in the back-office. Copied from the docs:

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!

Communicating with the web service requires an API key. You'll have to generate one for your Android app, again using the back-office:

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!

Finally, to get an overview of the API methods:

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:

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.

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.

The result should look somewhat like this (for version 1.5.4.1 of PrestaShop):

<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
  <api shop_name="MYSHOP">
    <addresses>...</addresses>
    <carriers>...</carriers>
    <cart_rules>...</cart_rules>
    <carts>...</carts>
    <categories>...</categories>
    <combinations>...</combinations>
    <configurations>...</configurations>
    <contacts>...</contacts>
    <content_management_system>...</content_management_system>
    <countries>...</countries>
    <currencies>...</currencies>
    <customer_messages>...</customer_messages>
    <customer_threads>...</customer_threads>
    <customers>...</customers>
    <deliveries>...</deliveries>
    <employees>...</employees>
    <groups>...</groups>
    <guests>...</guests>
    <image_types>...</image_types>
    <images>...</images>
    <languages>...</languages>
    <manufacturers>...</manufacturers>
    <order_carriers>...</order_carriers>
    <order_details>...</order_details>
    <order_discounts>...</order_discounts>
    <order_histories>...</order_histories>
    <order_invoices>...</order_invoices>
    <order_payments>...</order_payments>
    <order_states>...</order_states>
    <orders>...</orders>
    <price_ranges>...</price_ranges>
    <product_feature_values>...</product_feature_values>
    <product_features>...</product_features>
    <product_option_values>...</product_option_values>
    <product_options>...</product_options>
    <product_suppliers>...</product_suppliers>
    <products>...</products>
    <search >...</search>
    <shop_groups>...</shop_groups>
    <shops>...</shops>
    <specific_price_rules>...</specific_price_rules>
    <specific_prices>...</specific_prices>
    <states>...</states>
    <stock_availables>...</stock_availables>
    <stock_movement_reasons>...</stock_movement_reasons>
    <stock_movements>...</stock_movements>
    <stocks>...</stocks>
    <stores>...</stores>
    <suppliers>...</suppliers>
    <supply_order_details>...</supply_order_details>
    <supply_order_histories>...</supply_order_histories>
    <supply_order_receipt_histories>...</supply_order_receipt_histories>
    <supply_order_states>...</supply_order_states>
    <supply_orders>...</supply_orders>
    <tags>...</tags>
    <tax_rule_groups>...</tax_rule_groups>
    <tax_rules>...</tax_rules>
    <taxes>...</taxes>
    <translated_configurations>...</translated_configurations>
    <warehouse_product_locations>...</warehouse_product_locations>
    <warehouses>...</warehouses>
    <weight_ranges>...</weight_ranges>
    <zones>...</zones>
  </api>
  <api shop_name="MYOTHERSHOP">...</api>
  <api shop_name="YETANOTHERSHOP">...</api>
</prestashop>

Since you mention you're mainly interested in supporting basic/core functionality in the Android app, I'm inclined to say this probably fits your needs. :)

这篇关于如何prestashop与Android集成?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆