Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.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
Php Google Translator Toolkit API错误(“多部分必须具有Atom和媒体部分”)_Php_Api_Gdata Api - Fatal编程技术网

Php Google Translator Toolkit API错误(“多部分必须具有Atom和媒体部分”)

Php Google Translator Toolkit API错误(“多部分必须具有Atom和媒体部分”),php,api,gdata-api,Php,Api,Gdata Api,我尝试通过API将文档(srt字幕)上传到Google Translator Toolkit。 但我得到一个错误:“多部分必须有原子和媒体部分”。怎么了 我的请求: POST /toolkit/feeds/documents HTTP/1.1 Host: translate.google.com GData-Version: 1.0 Authorization: GoogleLogin Auth=[myauth] Content-Length: 404 Content-Type: multipa

我尝试通过API将文档(srt字幕)上传到Google Translator Toolkit。 但我得到一个错误:“多部分必须有原子和媒体部分”。怎么了

我的请求:

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
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--

说明标题和正文之间应该有一条空行

请求(第5节)和响应(第6节)消息使用RFC 822[9]的通用消息格式传输实体(消息的有效负载)。这两种类型的消息都由起始行、零个或多个标题字段(也称为“标题”)、指示标题字段结尾的空行(即CRLF前面没有任何内容的行)以及可能的消息正文组成

您的请求应如下所示:

POST/toolkit/feeds/documents HTTP/1.1
主持人:translate.google.com
GData版本:1.0
授权:GoogleLogin Auth=[myauth]
内容长度:404
内容类型:多部分/相关;边界=SKYqYanmBJWCtDU
Slug:test.srt
--SKYqYanmBJWCtDU
内容类型:应用程序/atom+xml;字符集=UTF-8
试验
EN
茹
--SKYqYanmBJWCtDU
内容类型:应用程序/x-subrip
数据
--SKYqYanmBJWCtDU--