Drupal通过Rest服务器登录 [英] Drupal login via Rest server

查看:155
本文介绍了Drupal通过Rest服务器登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用外部Drupal进行文章和页面的网站。
的目的是要表明仅使用HTML / CSS / JS在一个网站中的文章。

I'm developing a website who uses an external Drupal for the articles and pages. The purpose is to show the articles in a website using just html/css/js.

我添加了一个REST服务器模块Drupal的后台结束,所以我可以做http请求来审阅文章。现在从drupal后端作品中取回文章(见下面的代码)。 Restdrupal是我的网站和restendpoint的名称是REST服务器端点(上尉好明显)

I've added an Rest Server module to the drupal back-end so I can do http requests for retreiving the articles. Now retreiving the articles from the drupal back-end works (see code below). Restdrupal is the name of my site and restendpoint is the name of the Rest server's endpoint (Captian Obvious)

$.ajax({
    url : "http://127.0.0.1/restdrupal/restendpoint/node.json",
    dataType : 'json',
    success : function(data) {
              //further code
    }
});

现在我希望我的客户能够添加一些文章,所以我需要先登录。
我一直在互联网上搜索几天,尝试了一百万件事情,但对我来说没有任何效果。我试过的最新的东西(用jQuery)是这样的:

Now I want my customer to be able to add some articles, so I need to login first. I've been searching the internet for days now and tried a million things but nothing worked for me. The latest thing i've tried (with jQuery) was this :

$.ajax({
    url : "http://127.0.0.1/restdrupal/restendpoint/user/login",
    dataType:'application/json',
    type : 'PUT',
    data : 'Name=myusername&Pass=mypassword',
    success : function(data) {
        //further code
    },
    error:function(data){
           //Error handling
    }
});

我也将PUT更改为POST ...

I've also changed the PUT into POST...

我得到的答案是(不比我更好)我也是这样做的:

The response i'm getting is (no mather what I do) the same :

406 Not Acceptable: Unsupported request content type application/x-www-form-urlencoded

请问有人帮我吗?
亲爱的,
Ceetn

Could please somebody help me? Kind regards, Ceetn

推荐答案

你必须启用应用程序/ x-www-form-urlencoded您的服务端点的内容类型。

You have to enable application/x-www-form-urlencoded content type of your service endpoint.

执行以下操作:服务 - >编辑资源 - >选择选项卡服务器 - >启用application / x-www-form- urlencoded,那就是

Do as follows: Services -> Edit Resources -> select tab "Server" -> enable "application/x-www-form-urlencoded" and that's it

这篇关于Drupal通过Rest服务器登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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