Monday, 19 March 2012

Executing a URL within the app.

NSURL* url = [NSURL URLWithString:[NSString stringWithFormat:@"http://mma-in-nj.com/iphone/test/register_device.php?dt=%@",token]];
   NSLog(@"URL -- %@",url);
   
    NSMutableURLRequest *request1 = [[[NSMutableURLRequest alloc] init] autorelease];
    [request1 setURL:url];
    [request1 setHTTPMethod:@"GET"];
 
    [request1 setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    
   
    [NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[url host]];
   
    NSError *error;
    NSURLResponse *response;
    NSData *urlData=[NSURLConnection sendSynchronousRequest:request1 returningResponse:&response error:&error];
   
    NSString *data1=[[NSString alloc]initWithData:urlData encoding:NSUTF8StringEncoding];
    NSLog(@"here...%@",data1);  

No comments:

Post a Comment