Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

iVidCam Free
(free)

Kid Art
($0.99)

iPUBQUIZ
(£1.19)

ArtStudio
($3.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 08-29-2008, 10:18 AM   #10 (permalink)
uprise78
Registered Member
 
Join Date: Apr 2008
Posts: 159
Default

Client side code. Message was base64 encoded before being sent to this function.

Code:
- (void)sendSerializedGreeting:(NSString *)message
{
	// Show a loading indicator
	[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
	
	NSString *greetingURL = [NSString stringWithFormat:@"http://yourwebsite.com", [[UIDevice currentDevice] uniqueIdentifier]];
	NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:greetingURL]
															  cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];	
	
	NSDictionary *headerFieldsDict = [NSDictionary dictionaryWithObjectsAndKeys:@"text/xml; charset=utf-8", @"Content-Type", nil];
	
	[theRequest setHTTPBody:[message dataUsingEncoding:NSUTF8StringEncoding]];
	[theRequest setAllHTTPHeaderFields:headerFieldsDict];
	[theRequest setHTTPMethod:@"POST"];
	
	// create the connection with the request and start loading the data
	NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
	
	if (theConnection == nil)
	{
		NSLog(@"Failed to create the connection");
	}
}
Server side code:
// PHP
Code:
$file = base64_decode(file_get_contents("php://input"));
// ASP
Code:
StreamReader sr = new StreamReader(Page.Request.InputStream);
string file = Encoding.ASCII.GetString(Convert.FromBase64String(sr.ReadToEnd()));
uprise78 is offline   Reply With Quote
 
Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Stats
Members: 24,203
Threads: 38,982
Posts: 171,002
Top Poster: smasher (2,568)
Welcome to our newest member, sfeast
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:24 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.