Here is my php code.
public function PostCaseJson() {
$case = Input::get('keyword');
switch($case)
{
default:
{
$email = Input::get('email');
$password = Input::get('password');
$auth = $this->authenticationURL($email, $password);
$return = array('sc'=>$auth.'xx'.$case,'dt'=>$password);
}
}
return json_encode($return);
}
below is my Xcode code.
NSString *newUrl = [[NSString alloc] initWithFormat:@"http://xxxxxx.com/authentication/post"];
NSString *post = [NSString stringWithFormat:@"keyword=login&email=gggg@xxx.com&password=112211521"];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]init];
[request setURL:[NSURL URLWithString:newUrl]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"applcation/x-www-form-urlencoded;charset=UTF-8" forHTTPHeaderField:@"Content-Type"];
NSURLRequest *response;
NSData *POSTReply = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:nil];
NSString *theReply = [[NSString alloc] initWithBytes:[POSTReply bytes] length:[POSTReply length] encoding:NSASCIIStringEncoding];
NSLog(@"Reply: %@",theReply);
But at the end, i success reach the server, but the keyword, email and password seems like fail to reach the server. The results from server is just reach the url, but post nothing. i had try to return the keyword, email and password, it seems like don't have any value inside the parameter.
please help, thanks!