iphone - TTURLRequest and sending POST data -
i'm three20 first time on ios app, , i'm stuck on can find more information.
i'm trying send post data local server, everytime got response : error. if try parameters have no problem.
the code i'm using :
tturlrequest *request = [tturlrequest requestwithurl:@"http://127.0.0.1:8000/api/login" delegate:self]; request.cachepolicy = cachepolicy; request.response = [[[tturldataresponse alloc] init] autorelease]; request.httpmethod = @"post"; nsstring *myrequeststring = @"username=######@gmail.com&password=66ed############fxij"; nsdata *myrequestdata = [ nsdata datawithbytes: [ myrequeststring utf8string ] length: [ myrequeststring length ] ]; request.contenttype=@"application/x-www-form-urlencoded"; [request.parameters addobject:@"username" forkey:@"######@gmail.com"]; [request.parameters addobject:@"password" forkey:@"6ed############fxij"]; request.httpbody = myrequestdata;
thank help.
you have params backwards too! it. should be:
[request.parameter addobject:@"####@gmail.com" forkey:@"username"];
Comments
Post a Comment