-(void)httpRequestWithURL:(NSDictionary*)dic
{
self.requestParam=dic;
NSLog(@"httpRequestWithURL: %@", dic);
//请求参数dic
NSMutableDictionary* mutableDic = [[[NSMutableDictionary alloc] initWithDictionary:dic] autorelease];
if (self.isStandardIterface)
{
//baseURL地址
self.serverPath = [IHApiConfigManager configManager].appServer;
//对字典进行正序遍历
NSEnumerator* enumer = [[mutableDic allKeys] objectEnumerator];
NSString* key;
while (key = [enumer nextObject]) {
NSString* value = [mutableDic objectForKey:key];
if (![value isKindOfClass:[NSString class]])
{
value = [NSString stringWithFormat:@"%@", value];
[mutableDic setObject:value forKey:key];
}
}
//appkey作为参数
[mutableDic setObject:[IHApiConfigManager configManager].appKey forKey:@"appkey"];
//channel_id作为参数
[mutableDic setObject:[IHApiConfigManager configManager].channel_id forKey:@"channel_id"];
//api_version作为参数
[mutableDic setObject:[IHApiConfigManager configManager].apiVersion forKey:@"api_version"];
if (USERMODEL.sessionID==nil||[USERMODEL.sessionID length]==0)
{
}
else
{
[mutableDic setObject:USERMODEL.sessionID forKey:@"sessionid"];
}
//品牌,型号,操作系统,
NSString* ua = [[JLUainfo getInstance] getUA];
[mutableDic setObject:ua forKey:@"ua"];
//UUID
[mutableDic setObject:[IHUtility getUUID] forKey:@"deviceid"];
//imei
[mutableDic setObject:[IHUtility getIMEI] forKey:@"imei"];
//imsi
[mutableDic setObject:[IHUtility getIMSI] forKey:@"imsi"];
//时间
[mutableDic setObject:[IHUtility generateTimestamp] forKey:@"timestamp"];
[mutableDic setObject:[IHUtility generateNonce] forKey:@"nonce"];
// ihaaa.basfsfse.sysfss.initsfs
NSString* method = [mutableDic objectForKey:@"method"];
NSString* apiVersion = [IHApiConfigManager getAPIVersionWithMethod:method appKey:[IHApiConfigManager configManager].appKey];
if (apiVersion)
{
[mutableDic setObject:apiVersion forKey:@"api_version"];
}
}
//将字典
NSString* parameter = [IHUtility getParameterString:mutableDic];
//NSLog(@"paraString: %@", parameter);
NSString* url = [GJEncode URLEncode:self.serverPath];
NSString* paraEncodeString = [GJEncode URLEncode:parameter];
NSString* decRes = [NSString stringWithFormat:@"%@%@", url, paraEncodeString];
//NSLog(@"decRes:%@", decRes);
decRes = [IHUtility base64StringWithHMACSHA1Digest:decRes key:[IHApiConfigManager configManager].appSecret];
NSString* signature = [GJEncode URLEncode:decRes];
//NSLog(@"signature:%@", signature);
NSMutableDictionary* dict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"json2",@"contentformat",
@"gzip" ,@"Accept-Encoding",
nil];
NSString* u = self.serverPath;
if (!self.isStandardIterface) {
u=[NSString stringWithFormat:@"%@?%@&sign=%@",self.serverPath,parameter,signature];
}
[self.httpRequest preCreateConnectRequestWithURL:u];
[self.httpRequest setHttpHeader:dict];
[self.httpRequest setHttpMethod:@"POST"];
NSString* postStr = [NSString stringWithFormat:@"%@&sign=%@", parameter, signature];
NSLog(@"total url: %@?%@", self.serverPath, postStr);
[self.httpRequest setHttpBody:[postStr dataUsingEncoding:NSUTF8StringEncoding]];
[self setHttpConnectFinishedMethod:self.httpRequest];
[self.httpRequest startCreatedConnectWithFurtherInfo:nil];
}
{
"api_version" = 2;
appkey = 1111;
"channel_id" = 2222;
deviceid = "";
imei =;
imsi =;
method = "";
nonce = "";
pixel = 640x960;
timestamp =;
ua = "";
}