tags:

views:

33

answers:

1

http://something.php?ownerID=13&view=userAgreement i need to pass two variables to this .. how can i pass these i am declared ownerid to 13 in my config playlist and i am able to get it ,how to set "view = useragreement" string to view variable....

can any body show me sample code.. i am using like

NSString* termsURL = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"termsURL"];
 NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@%@%@%@", termsURL, @"?ownerID=", ownerID,@"?view=",userAgreement]];

but is not working,i am checking parsing is success or not with this url but is failing...

A: 

Code taken straight from my app. It works for what you need

NSString *post = [NSString stringWithFormat:@"ownerID=13&view=userAgreement"];

NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];

NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];

//set up the request to the website
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];

[request setURL:[NSURL URLWithString:@"http://something.php"]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];

[request setHTTPBody:postData];
NSError *error;
NSURLResponse *response;

NSData *urlData=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSString *result3=[[[NSString alloc]initWithData:urlData encoding:NSUTF8StringEncoding]autorelease];
E. Criss
i want exactly ,wat is wrong with my code
lak in iphone
well for one you are going to have two '?' in the php string which is wrong you can only have one in the beginning. You really haven't given enough code to let me see what else could possibly be going wrong. Again though just copy paste my code in your project and format the "post" string and it will work
E. Criss