2013-12-11 32 views

回答

0
//Create the request 

NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"your script name.php"]]; 
// create the Method "GET" or "POST" 

[request setHTTPMethod:@"POST"]; 

    //Pass The String to server 
NSString *userUpdate =[NSString stringWithFormat:@"artist_email=%@ ",your string Name,nil]; 

//Check The Value what we passed 
NSLog(@"the data Details is =%@", userUpdate); 

//Convert the String to Data 
NSData *data1 = [userUpdate dataUsingEncoding:NSUTF8StringEncoding]; 

//Apply the data to the body 
[request setHTTPBody:data1]; 

//Create the response and Error 

NSError *err; 
NSURLResponse *response; 

NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&err]; 

NSString *resSrt = [[NSString alloc]initWithData:responseData encoding:NSASCIIStringEncoding]; 

//This is for Response 
NSLog(@"got response==%@", resSrt); 

if(resSrt) 
{ 
    NSLog(@"got response"); 


} 
else 
{ 
    NSLog(@"faield to connect"); 
} 
0

我会建议使用它同时支持JSON和XML的开箱和发展,是因为你不必JSON数据的解析管理,并从C#对象相对简单的ASP.NET Web API,你可以那么只需使用Entity Framework与数据库进行通信即可。

开始:http://www.asp.net/web-api/overview/creating-web-apis/creating-a-web-api-that-supports-crud-operations

和:http://www.entityframeworktutorial.net/EntityFramework4.3/Introduction.aspx我觉得这是一个有点过时,但核心将保持不变