0

我正在尝试发布此帖子,但我无法实现。执行 HttpPost 时我的代码失败

这是帖子:

https://eu.api.mega.co.nz/cs?id=1746599986
POST /cs?id=1746599986 HTTP/1.1
Host: eu.api.mega.co.nz
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:18.0) Gecko/20100101 Firefox/18.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: es-ar,es;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Referer: https://mega.co.nz/
Content-Length: 67
Content-Type: text/plain; charset=UTF-8
Origin: https://mega.co.nz
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
[{"a":"us","user":"example@example.com","uh":"XXXXXXX"}]

HTTP/1.1 200 OK
Content-Type: application/json
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept
Content-Encoding: gzip
Content-Length: 1014
Connection: Keep-Alive

这是我的代码:

String url = "https://eu.api.mega.co.nz/cs?id=";
Random random = new Random();

HttpClient mHttpClient = new DefaultHttpClient();

HttpPost mHttpPost = new HttpPost(mMegaUrl + random.nextInt(1999999999).toString());
mHttpPost.setHeader("Content-Type", "text/plain; charset=UTF-8");

String json = "[{'a':'us', 'user':'example@example.com', 'uh':'XXXXXXXX'}]";
mHttpPost.setEntity(new ByteArrayEntity(json.getBytes("UTF8")));

HttpResponse mHttpResponse = mHttpClient.execute(mHttpPost);

提前致谢

4

0 回答 0