我想使用mIRC在Dropbot 上创建一个文件夹
但回声总是得到这样的信息:
400 Bad Request
The plain HTTP request was sent to HTTPS port
我不知道为什么会发生这种事。这是我的代码:
alias dropboxCreateFolder {
sockclose dropboxCreateFolder
sockopen dropboxCreateFolder api.dropboxapi.com 443
}
ON *:SOCKOPEN:dropboxCreateFolder: {
if ($sockerr) { sockclose $sockname | halt }
var %data = {"path":"/myfile/songs"}
sockwrite -nt $sockname POST /2/files/create_folder HTTP/1.1
sockwrite -nt $sockname Host: api.dropboxapi.com
sockwrite -nt $sockname User-Agent: api-explorer-client
sockwrite -nt $sockname Authorization: Bearer Access_Token
sockwrite -nt $sockname Content-Type: application/json
sockwrite -nt $sockname $crlf $+ %data
}
ON *:SOCKREAD:dropboxCreateFolder: {
if ($sockerr) { sockclose $sockname | halt }
else {
var %sockreader | sockread %sockreader
echo -s %sockreader
}
}
1-您没有使用SSL。这是API的升降箱要求。
2-你没有设置Content-Length标题,你真的应该在发布时这样做。
alias dropboxCreateFolder {
sockclose dropboxCreateFolder
sockopen -e dropboxCreateFolder api.dropboxapi.com 443
}
ON *:SOCKOPEN:dropboxCreateFolder: {
if ($sockerr) { sockclose $sockname | halt }
var %data = {"path":"/myfile/songs"}
sockwrite -nt $sockname POST /2/files/create_folder HTTP/1.1
sockwrite -nt $sockname Host: api.dropboxapi.com
sockwrite -nt $sockname User-Agent: api-explorer-client
sockwrite -nt $sockname Authorization: Bearer Access_Token
sockwrite -nt $sockname Content-Type: application/json
sockwrite -nt $sockname Content-Length: $len(%data)
sockwrite -nt $sockname $crlf $+ %data
}
ON *:SOCKREAD:dropboxCreateFolder: {
if ($sockerr) { sockclose $sockname | halt }
else {
var %sockreader | sockread %sockreader
echo -s %sockreader
}
}
您显示的错误告诉您向HTTPS端口发送了纯HTTP请求。这意味着api.dropboxapi.com希望在端口443上进行SSL连接,但您正在尝试创建非SSL连接。
您需要在sockopen命令中指定-e
开关来创建SSL连接。