Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/470.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Soup-带身份验证的POST请求_Javascript_Authentication_Gnome Shell_Gnome Shell Extensions - Fatal编程技术网

Javascript Soup-带身份验证的POST请求

Javascript Soup-带身份验证的POST请求,javascript,authentication,gnome-shell,gnome-shell-extensions,Javascript,Authentication,Gnome Shell,Gnome Shell Extensions,我正在开发一个Gnome外壳扩展,我一直在使用Soup联系服务器。 基本上,我想发送一个POST请求,它可以在身份验证后执行。如果经过身份验证,则响应为JSON内容,如果未经过身份验证,则响应内容为HTML,即站点的欢迎页面。 以下是我目前的代码: let session=new Soup.SessionSync(); session.user_agent=Me.metadata.uuid; 让authParams={'login':'xxx','password':'xxx'}; 让mess

我正在开发一个Gnome外壳扩展,我一直在使用Soup联系服务器。 基本上,我想发送一个POST请求,它可以在身份验证后执行。如果经过身份验证,则响应为JSON内容,如果未经过身份验证,则响应内容为HTML,即站点的欢迎页面。 以下是我目前的代码:

let session=new Soup.SessionSync();
session.user_agent=Me.metadata.uuid;
让authParams={'login':'xxx','password':'xxx'};
让message=Soup.form_request_new_from_hash('POST',authURL,authParams);
session.queue_消息(消息,Lang.bind)(此,函数(会话,响应){
global.log('AUTHENTICATE:'+response.status_code+'-'+response.reason_短语);
global.log('AUTHENTICATE:'+response.response\u body.data);
让msg=Soup.form_request_new_from_hash('POST',url,params);
session.queue_消息(msg,Lang.bind)(此,函数(会话,响应){
global.log(response.status_code+'-'+response.reason_短语);
global.log(response.response_headers.get_one('content-type');
}));
}));
let session=new Soup.SessionSync();
session.user_agent=Me.metadata.uuid;
让authParams={'login':'xxx','password':'xxx'};
让message=Soup.form_request_new_from_hash('POST',authURL,authParams);
session.queue_消息(消息,Lang.bind)(此,函数(会话,响应){
global.log('AUTHENTICATE:'+response.status_code+'-'+response.reason_短语);
global.log('AUTHENTICATE:'+response.response\u body.data);
让msg=Soup.form_request_new_from_hash('POST',url,params);
session.queue_消息(msg,Lang.bind)(此,函数(会话,响应){
global.log(response.status_code+'-'+response.reason_短语);
global.log(response.response_headers.get_one('content-type');
}));
}));
let session=new Soup.SessionSync();
session.user_agent=Me.metadata.uuid;
让authParams={'login':'xxx','password':'xxx'};
让message=Soup.form_request_new_from_hash('POST',authURL,authParams);
session.queue_消息(消息,Lang.bind)(此,函数(会话,响应){
global.log('AUTHENTICATE:'+response.status_code+'-'+response.reason_短语);
global.log('AUTHENTICATE:'+response.response\u body.data);
让msg=Soup.form_request_new_from_hash('POST',url,params);
session.queue_消息(msg,Lang.bind)(此,函数(会话,响应){
global.log(response.status_code+'-'+response.reason_短语);
global.log(response.response_headers.get_one('content-type');
}));
}));