2014-07-07 56 views
0

我可以看到30个用户ID的历史通过这个网址获取JSON数据按照用户ID

http://userhistory.in/UserImage.svc/GetUnAnsweredImagesLog?UserId=30 

,但在这里,用户标识是可变的基础上,用户注册生成。我只是尝试下面的代码来获取历史。而不是30位用户返回所有用户的历史记录。

NSString *[email protected]"30"; 
    int i=[userID2 intValue]; 


    NSString *urlString=[NSString stringWithFormat:@"http://37.187.152.236/UserImage.svc/GetUnAnsweredImagesLog?%d",i]; 
    NSLog(@"url : %@",urlString); 
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlString] 
                  cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData 
                 timeoutInterval:10]; 

    [request setHTTPMethod: @"POST"]; 

这里是静态地传递用户ID。如果代码工作正常,那么我会从注册response.apart中获取它,我需要获取特定的userid历史记录。

+0

我想,有什么不对您的服务器数据库,API开发人员不过滤用户历史记录结果。 'SELECT * FROM USER_HISTORY;'而不是''SELECT * FROM USER_HISTORY WHERE USER_ID = 30;'应用程序代码没有问题。 – Hemang

回答

0

只是改变你的网址

NSString *urlString=[NSString stringWithFormat:@"http://37.187.152.236/UserImage.svc/GetUnAnsweredImagesLog?%d",i]; 

NSString *[email protected]"30"; 
int i=[userID2 intValue]; 

this is for int method 

    NSString *urlString=[NSString stringWithFormat:@"http://37.187.152.236/UserImage.svc/GetUnAnsweredImagesLog?UserId=%d",i]; 

其他明智 这是对字符串的方法

NSString *urlString=[NSString stringWithFormat:@"http://37.187.152.236/UserImage.svc/GetUnAnsweredImagesLog?UserId=%@", userID2]; 


[request setHTTPMethod: @"GET"]; 
+0

真棒回答....非常感谢 –

+0

@Hemang为什么你给了反对票,可以看到网址,关键用户ID是否丢失 –

+1

URL中不应该有空格 – Apurv