我正在尝试将数据从目标 C 发布到服务器,并尝试在其中JSON
返回。
我正在查看 Snaphax APIPHP
和 Snaphaxpy API,并尝试将其从 PHP 重写为 Objective C。代码的链接是:
https ://github.com/tlack/snaphax
https://github.com/jasonanovak/ snaphaxpy/blob/master/snaphaxpy.py
我还特别关注:http: //adamcaudill.com/2012/06/16/snapchat-api-and-security/ 但显然这已经过时了
我的代码是:
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"https://feelinsonice.appspot.com/ph/login"]];
[request setHTTPMethod:@"POST"];
[request addValue:@"******testusername******" forHTTPHeaderField:@"username"];
[request addValue:@"*********" forHTTPHeaderField:@"password"];
[request addValue:@"M02cnQ51Ji97vwT4" forHTTPHeaderField:@"blob_enc_key"];
[request addValue:@"false" forHTTPHeaderField:@"debug"];
[request addValue:@"iEk21fuwZApXlz93750dmW22pw389dPwOk" forHTTPHeaderField:@"secret"];
[request addValue:@"m198sOkJEn37DjqZ32lpRu76xmw288xSQ9" forHTTPHeaderField:@"static_token"];
[request addValue:@"Snaphax 4.0.1 (iPad; iPhone OS 6.0; en_US)" forHTTPHeaderField:@"user_agent"];
[request addValue:@"930cf95a6731dc986ef3bceef6abbaf420e94d8d197dca87b9b47314d8c51b3b" forHTTPHeaderField:@"req_token"];
[request addValue:@"1355776346532" forHTTPHeaderField:@"timestamp"];
NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *dataString = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
NSLog(@"%@", dataString);
我没有包括一个真正的username/password
. 但是,为什么这不起作用,因为我已经复制了我发现并用一种新语言实现的所有内容......
我没有正确发布数据吗?我尝试使用ASIHTTPRequest
,但我也无法让它工作......
基于经验的任何建议或想法?