NSMutableURLRequest google my maps help
NSMutableURLRequest google my maps help
- Subject: NSMutableURLRequest google my maps help
- From: Philip Vallone <email@hidden>
- Date: Sun, 24 Oct 2010 16:26:34 -0400
Hi,
I am trying to upload a xml file to google my maps that follows the following protocol:
http://code.google.com/apis/maps/documentation/mapsdata/developers_guide_protocol.html#uploading_xml
POST http://maps.google.com/maps/feeds/maps/userID/full
Content-type: application/atom+xml
Authorization: GoogleLogin auth="authorization_token"
<entry xmlns="http://www.w3.org/2005/Atom">
<title>My Map</title>
<summary>My Description</summary>
</entry>
I am using the following code:
if (appDelegate.authGoogleKey != nil) {
NSString *urlStr = [NSString stringWithFormat:@"//maps.google.com/maps/feeds/maps/%@/full", txtEmail.text];
NSURL *url = [NSURL URLWithString:urlStr];
NSMutableURLRequest *uploadRequest = [NSMutableURLRequest requestWithURL:url];
[uploadRequest setHTTPMethod:@"POST"];
//set headers
[uploadRequest addValue:@"Content-Type" forHTTPHeaderField:@"application/atom+xml"];
[uploadRequest addValue:@"Authorization" forHTTPHeaderField:@"GoogleLogin"];
[uploadRequest addValue:@"auth" forHTTPHeaderField:appDelegate.authGoogleKey];
NSString *requestBody = @"<entry xmlns=\"http://www.w3.org/2005/Atom\"><title>My Map</title><summary>My Description</summary></entry>";
[uploadRequest setHTTPBody:[requestBody dataUsingEncoding:NSASCIIStringEncoding]];
NSData *returnData = [NSURLConnection sendSynchronousRequest:uploadRequest returningResponse:nil error:nil];
NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];
NSLog(@"Response: %@ ", returnString);
[returnString release];
}else{
NSLog(@"Not logged in");
}
I am not getting a response back, which indicates my post method is wrong. Can anyone help me out?
Thanks,
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden