Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -(void)getUserNameStr: (NSString*)newUsername withPassword: (NSString*)newPassword{
- NSString*urlStr = @"http://taxi.expertverification.com/api/v1/ValidUser?";
- NSString * myRequestString =[NSString stringWithFormat:@"%@UserName=%@&Password=%@",
- urlStr,
- newUsername,
- newPassword];
- NSData *myRequestData = [NSData dataWithBytes: [myRequestString UTF8String] length: [myRequestString length]];
- NSMutableURLRequest *request = [[NSMutableURLRequest alloc]init];
- [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"];
- [request setHTTPMethod: @"POST"];
- //post section
- [request setHTTPBody: myRequestData];
- NSURLSession *session = [NSURLSession sharedSession];
- [[session dataTaskWithURL:[NSURL URLWithString:myRequestString]
- completionHandler:^(NSData *data,
- NSURLResponse *response,
- NSError *error) {
- // handle response
- NSString *requestReply = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
- NSLog(@"requestReply: %@", requestReply);
- }] resume];
- }
- requestReply: {"Message":"The requested resource does not support http method 'GET'."}
- ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
- Log.d(TAG, "ba1: "+ba1);
- nameValuePairs.add(new BasicNameValuePair("UserName", "rkb");
- nameValuePairs.add(new BasicNameValuePair("Password", "rkb");
- try{
- HttpClient httpclient = new DefaultHttpClient();
- HttpPost httppost = new HttpPost("http://taxi.expertverification.com/api/v1/ValidUser?";
- httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
- HttpResponse response = httpclient.execute(httppost);
- HttpEntity entity = response.getEntity();
- String outPut = EntityUtils.toString(entity);
- Log.i("GET RESPONSE—-", outPut);
- Log.e("log_tag ******", "good connection";
- bitmapOrg.recycle();
- }catch (Exception e) {
- Log.e("log_tag ******", "Error in http connection " + e.toString());
- }
- true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement