使用curl模拟Gmail请求

时间:2013-04-21 14:36:36

标签: json post curl gmail http-post

我正在尝试模拟gmail请求。基本上我打算获取所有json响应。

当您点击Gmail中的Themes -> Change you background image时,您会看到一个picasa精选图库,您可以从中选择图片。我设法获取POST字符串gmail用于使用chrome developer tools -> Network -> XHR获取更多图像的请求。我将请求复制为curl。

curl "https://mail.google.com/picker/pvr?hl=en&native=1&hostId=gm-theme" -H ":host: mail.google.com" -H ":version: HTTP/1.1" -H "origin: https://mail.google.com" -H "accept-encoding: gzip,deflate,sdch" -H "accept-language: en-US,en;q=0.8" -H "content-control: no-cache" -H "cookie: GMAIL-COOKIES" -H "content-length: 257" -H ":path: /picker/pvr?hl=en&native=1&hostId=gm-theme" -H "accept-charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3" -H "user-agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31" -H "content-type: application/x-www-form-urlencoded;charset=UTF-8" -H "accept: */*" -H "referer: https://mail.google.com/_/mail-static/_/js/main/m_i,t/rt=h/ver=NB-HmMH_MVQ.en./sv=1/am=!JjrcIo7GA7b0RPF-I9tbYvMmngnebTyl_O_8x6inji58opxSrbuft8sKd6tLvMR8EoLV76U/d=1?random=1366542355442" -H "x-same-domain: explorer" -H ":scheme: https" -H ":method: POST" --data "start=2050&numResults=50&sort=3&desc=true&data=0&view=2&service=picasa&type=featured&options=%7B%22excludeLabels%22%3Anull%7D&token=MY-TOKEN&version=4&subapp=5&app=2&clientUser=16140887335626099390&authuser=0"


当我在curl中运行它时,我收到一个混淆/加密的文本,而不是接收json文件,例如:link

为什么响应不是这样的json文本:link

1 个答案:

答案 0 :(得分:1)

结果与您忘记解压缩结果相同。如果我将您的abc.json重命名为abc.json.gz并提取abc.json,我将获得与您的normal.json相同的结果。

<强> normal.json

&&&START&&&{"response":{"cursor":"2100","docs":[{"attrs":{"ut":1.20922026E12}...

abc.json (解压后):

&&&START&&&{"response":{"cursor":"50","docs":[{"attrs":{"ut":1.364824967E12}...