我需要从 Google Voice 登录发布请求中取回 gvx cookie,以便进行直接访问号码呼叫。据我了解,一旦登录,Google Voice 将在标识为移动设备的客户端上设置一个 gvx cookie(我已设置正确的用户代理)。
我可以使用此 URL Post Request 成功登录:
https://accounts.google.com/ServiceLogin?ltmpl=mobile&btmpl=mobile&Email=username%40gmail.com&Passwd=mypassword&service=grandcentral&continue=https%3A%2F%2Fwww.google.com%2Fvoice%2Fm&timeStmp=&secTok=&signIn=Sign+in
和用户代理:
Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5
Objective-C 代码:
NSString *data = [NSString stringWithFormat:@"ltmpl=mobile&btmpl=mobile&Email=%@&Passwd=%@&service=grandcentral&continue=%@&timeStmp=&secTok=&signIn=Sign+in", self.user.urlEncoded, self.password.urlEncoded, [NSString stringWithFormat:@"https://www.google.com/voice/m"].urlEncoded ];
if (captchaResponse && captchaToken) {
data = [data stringByAppendingFormat: @"&logintoken=%@&logincaptcha=%@",
captchaToken.urlEncoded,
captchaResponse.urlEncoded];
}
NSData *requestData = [NSData dataWithBytes: [data UTF8String] length: [data length]];
NSURL *url = [NSURL URLWithString: LOGIN_URL_STRING];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL: url];
[request setHTTPMethod: @"POST"];
[request setHTTPBody: requestData];
[request setValue: USER_AGENT_IPHONE forHTTPHeaderField: USER_AGENT_HEADER];
NSURLResponse *resp = nil;
NSError *err = nil;
NSData *response = [NSURLConnection sendSynchronousRequest: request returningResponse: &resp error: &err];
self.general = [dict objectForKey: RAW_DATA];
if (self.general) {
self.rnrSe = [self discoverRNRSE];
}
[self fetchSettings];
NSHTTPCookie *cookie;
NSHTTPCookieStorage *cookieJar = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (cookie in [cookieJar cookies]) {
NSLog(@"%@", cookie);
}
我从 cookie 中得到的只有 3 个名字:
GALX - with some random characters and numbers value
GAPS - with some random characters and numbers value
S - with value: "grandcentral=xxxxxx..xxxx"
我应该在 Cookie 中获得更多信息,例如:
HSID, SSID, APISID, PREF, NID
最重要的是gvx
饼干。这就是我要找的。
如何获取 gvx cookie?