gpt4 book ai didi

php - 谷歌翻译工具包 API 错误 ("Multipart must have Atom and media part")

转载 作者:搜寻专家 更新时间:2023-10-31 21:17:41 24 4
gpt4 key购买 nike

我尝试通过 API 将文档(srt 字幕)上传到 Google Translator Toolkit。但是我得到一个错误:“Multipart 必须有 Atom 和 media 部分”。怎么了?

我的要求:

POST /toolkit/feeds/documents HTTP/1.1
Host: translate.google.com
GData-Version: 1.0
Authorization: GoogleLogin Auth=[myauth]
Content-Length: 404
Content-Type: multipart/related; boundary=SKYqYanmBJWCtDU
Slug: test.srt
--SKYqYanmBJWCtDU
Content-Type: application/atom+xml; charset=UTF-8

<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:gtt="http://schemas.google.com/gtt/2009/11">
<title>test</title>
<gtt:sourceLanguage>en</gtt:sourceLanguage>
<gtt:targetLanguage>ru</gtt:targetLanguage>
</entry>
--SKYqYanmBJWCtDU
Content-Type: application/x-subrip

data
--SKYqYanmBJWCtDU--

回答:

HTTP/1.1 400 Bad Request
Content-Type: text/html; charset=UTF-8
Date: Mon, 21 Feb 2011 18:20:24 GMT
Expires: Mon, 21 Feb 2011 18:20:24 GMT
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
Connection: close
Transfer-Encoding: chunked

27
Multipart must have Atom and media part
0

Link to Google Translator Toolkit Data API Reference Guide v1.0

最佳答案

HTTP/1.1 specification指出应该有一个空行分隔标题和正文。

Request (section 5) and Response (section 6) messages use the generic message format of RFC 822 [9] for transferring entities (the payload of the message). Both types of message consist of a start-line, zero or more header fields (also known as "headers"), an empty line (i.e., a line with nothing preceding the CRLF) indicating the end of the header fields, and possibly a message-body.

您的请求应如下所示:

POST /toolkit/feeds/documents HTTP/1.1
Host: translate.google.com
GData-Version: 1.0
Authorization: GoogleLogin Auth=[myauth]
Content-Length: 404
Content-Type: multipart/related; boundary=SKYqYanmBJWCtDU
Slug: test.srt

--SKYqYanmBJWCtDU
Content-Type: application/atom+xml; charset=UTF-8

<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:gtt="http://schemas.google.com/gtt/2009/11">
<title>test</title>
<gtt:sourceLanguage>en</gtt:sourceLanguage>
<gtt:targetLanguage>ru</gtt:targetLanguage>
</entry>
--SKYqYanmBJWCtDU
Content-Type: application/x-subrip

data
--SKYqYanmBJWCtDU--

关于php - 谷歌翻译工具包 API 错误 ("Multipart must have Atom and media part"),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5069872/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com