Ajouter un nouvel endroit à Google Adresses

Je suis nouveau à IOS. Je dois append de nouveaux lieux à Google Adresses. J'ai référé ce lien https://developers.google.com/places/documentation/actions pour append une place au clic du button, mais je suis confus au sujet de la transmission des parameters pour cela.

Mes lignes de encoding sont comme ceci:

NSSsortingng *lat =@"-33.8669710"; NSSsortingng *longt =@"151.1957362"; gKey = @"my api key"; NSSsortingng *placeSsortingng = [NSSsortingng ssortingngWithFormat:@"https://maps.googleapis.com/maps/api/place/add/json?sensor=false&key=%@HTTP/1.1Host:maps.googleapis.com {\"location\":{\"lat\":%@,\"lng\":%@},\"accuracy\": 50,\"name\":\"Gimmy Pet Store!\",\"types\":[\"pet_store\"],\"language\":\"en-AU\"}",gKey,lat,longt]; placeSsortingng = [placeSsortingng ssortingngByAddingPercentEscapesUsingEncoding:NSUTF8SsortingngEncoding]; NSLog(@"Main Place Url: %@",placeSsortingng); NSURL *placeURL = [NSURL URLWithSsortingng:placeSsortingng]; NSMutableURLRequest *request=[NSMutableURLRequest requestWithURL:placeURL]; [request setHTTPMethod:@"POST"]; NSURLConnection *placesConn =[[NSURLConnection alloc] initWithRequest:request delegate:self]; 

J'ai fait les changements suivants à mon code et enfin il est exécuté avec succès …

 //for setting Parameters to post the url.just change tag values to below line... NSSsortingng *str1 = [NSSsortingng ssortingngWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><PlaceAddRequest><location><lat>your latitude</lat><lng>your longitude</lng></location><accuracy>50</accuracy><name>place name</name><type>supported type</type><language>en-US</language></PlaceAddRequest>"]; NSLog(@"str1=====%@",str1); NSSsortingng *str2 = [str1 ssortingngByAddingPercentEscapesUsingEncoding:NSUTF8SsortingngEncoding]; NSData *requestdata = [NSData dataWithBytes:[str2 UTF8Ssortingng] length:[str2 length]]; NSSsortingng *postLength = [NSSsortingng ssortingngWithFormat:@"%d", [requestdata length]]; //requesting main url to add new place to google places NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithSsortingng:@"https://maps.googleapis.com/maps/api/place/add/xml?sensor=false&key=your api key"]]; [request setValue:postLength forHTTPHeaderField:@"Content-Length"]; [request setValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; [request setHTTPMethod:@"POST"]; [request setHTTPBody:[NSData dataWithBytes:[str1 UTF8Ssortingng] length:[str1 length]]]; //NSURLConnection *placesConn =[[NSURLConnection alloc] initWithRequest:request delegate:self]; NSData *returndata = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]; NSSsortingng *returnstr = [[[NSSsortingng alloc] initWithData:returndata encoding:NSUTF8SsortingngEncoding] autorelease]; NSLog(@"returnstr: %@",returnstr); 

& puis j'ai décodé réponse de return que je reçois le statut comme OK …… 🙂

Tout le monde peut utiliser le code ci-dessus … si vous avez besoin d'aide, vous pouvez certainement requestr …. 🙂