tags:

views:

48

answers:

2

hey can any one suggest me is there any API or example for authenticating email addresses in iphone app

+1  A: 

You need to use regular expression to check email validation.

You can do a simple test:

NSString *emailRegEx = @"(?:[a-z0-9!#$%\\&'*+/=?\\^_{|}~-]+(?:\.[a-z0-9!#$%\&'*+/=?\^_{|}" @"~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\" @"x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-" @"z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5" @"]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-" @"9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21" @"-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])";

NSPredicate *regExPredicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegEx];

BOOL myStringMatchesRegEx = [regExPredicate evaluateWithObject:myString];

The only question that remains is: what is a regular expression that can be used to verify that an NSString contains a syntactically valid email address?

iPhoneDev
not validating the email authenticating mails like gmail,hotmail etc.
white
check the edited code
iPhoneDev
this is not exactly what i want, me want to validate real mail ids andpasswords of messengers
white
Do u mean checking it from server? If this, you need to send an HTTP request to server. For that there is no API present in iPhone. u need to write code.
iPhoneDev
thanx for the info can you suggest me any example or post some code for this waiting for response
white
A: 

Try this..

NSString * xmlString = @"Hello"; NSURL * serviceUrl = [NSURL URLWithString:@"http://my.company.com/myservice"]; NSMutableURLRequest * serviceRequest = [NSMutableURLRequest requestWithURL:serviceUrl]; [serviceRequest setValue:@"text/xml" forHTTPHeaderField:@"Content-type"]; [serviceRequest setHTTPMethod:@"POST"]; [serviceRequest setHTTPBody:[xmlString dataUsingEncoding:NSASCIIStringEncoding]];

NSURLResponse * serviceResponse; NSError * serviceError; serviceResponse = [NSURLConnection sendSynchronousRequest:serviceRequest returningResponse:&serviceResponse error:&serviceError];

iPhoneDev
thanx mate i got Auth key and i need to use it for login how can i do that work please post some code or suggest any url or example
white