从JavaScript访问Prestashop webservice [英] Access Prestashop webservice from JavaScript

查看:83
本文介绍了从JavaScript访问Prestashop webservice的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Prestashop后端,我激活了webservice并创建了一个身份验证密钥。在浏览器中进行测试效果很好但现在我想在Cordova应用程序中通过JavaScript访问web服务。

In the Prestashop backend I activated the webservice and I created an authentication key. Testing in browser works well but now I want to access the webservice via JavaScript in a Cordova application.

我得到的响应是 401(未经授权)。我正在执行此ajax调用(使用AngularJS):

The response I am getting is 401 (Unauthorized). I'm performing this ajax call (using AngularJS):

$http.get('http://AUTHENTICATION_KEY@url.com/api/employees/2', {})

如何发送身份验证密钥?

How do I have to send the authentication key?

我一直在互联网上搜索,但我没有发现任何有趣的东西来解决我的问题。

I've been searching on the Internet but I did not found anything interesting that solves my problem.

推荐答案

最后,我想出了如何发送ws_key:

Finally, I figured out how to send the ws_key:

$http({
        method: 'get',
        url: ws_url + 'customers/?schema=blank',
        params: {
            ws_key: ws_key
        });

您必须使用密钥传递ws_key参数才能访问PrestaShop Web服务。

You have to pass the ws_key param with your key to access the PrestaShop webservice.

这篇关于从JavaScript访问Prestashop webservice的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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