これは私が認証する必要がある私のphpです:
<?php
$username=$_POST["m_username"];
$password=$_POST["m_password"];
/*
$username=$_GET["m_username"];
$password=$_GET["m_password"];
*/
?>
iPhoneアプリからの認証に以下のコードを使用しています。しかし、それは認証ではありません。それが機能しないという問題が何であるかわかりません。送信されたnullパラメータ/値を示します。
NSString *urlAsString =[NSString stringWithFormat:@"http://www.myurl.com/abc/authenticate.php"];
NSURL *url = [NSURL URLWithString:urlAsString];
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:url];
[urlRequest setTimeoutInterval:30.0f];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest addValue:@"test" forHTTPHeaderField:@"m_username" ];
[urlRequest addValue:@"123" forHTTPHeaderField:@"m_password" ];
[[NSURLConnection alloc] initWithRequest:urlRequest delegate:self];
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
[NSURLConnection sendAsynchronousRequest:urlRequest queue:queue completionHandler:^(NSURLResponse *response,NSData *data, NSError *error) {
if ([data length] >0 && error == nil){
html = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"HTML = %@", html);
receivedData = [NSMutableData data];
}
else if ([data length] == 0 && error == nil){
NSLog(@"Nothing was downloaded.");
}
else if (error != nil){
NSLog(@"Error happened = %@", error);
}
}];
// Start loading data
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self];
if (theConnection)
{
// Create the NSMutableData to hold the received data
receivedData = [NSMutableData data];
}
else {
// Inform the user the connection failed.
}