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 04-11-2008, 07:40 PM   #1 (permalink)
CoffeeKid
Guest
 
Posts: n/a
Default Pulling Data From A Web Page

Hi Everyone,

I'm trying to use the CFHTTPRequest library to pull data from a web page. All the web page has is a pipe deliminated string of some information about our server status. I want to pull this into the iPhone and display it in a pretty gui interface.

My issue is that i can't figure out how to get the body of the web page. I've looked through a few examples and I keep getting lost. Below is the code i'm using, please give me some idea on how i would get the body, and then throw it into a string where i can then put the data into variables within a class.

Code:
	CFHTTPMessageRef request;
	CFReadStreamRef stream;
	//init: url is a string like "www.someplace.com"
	NSString *theURL = [NSString stringWithFormat:@"http://%@", url];
	NSURL *urlObj = [NSURL URLWithString:theURL];
	

	request = CFHTTPMessageCreateRequest(kCFAllocatorDefault, CFSTR("GET"), (CFURLRef)urlObj, kCFHTTPVersion1_0);
	//fetch	
	stream = CFReadStreamCreateForHTTPRequest(kCFAllocatorDefault,request);
	
	CFReadStreamScheduleWithRunLoop(stream, CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
	
	CFHTTPMessageRef response = (CFHTTPMessageRef) CFReadStreamCopyProperty(stream, kCFStreamPropertyHTTPResponseHeader);
	
        //not sure if this is correct :(
	CFDataRef *body = CFHTTPMessageCopyBody(response);

       //now what?

Am I heading in the right direction? Or is there a better way to do this?

If I am doing it right, how do I turn body into a string of actual text that I can manipulate?

Thanks,
CoffeeKid
  Reply With Quote
 
Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Stats
Members: 24,243
Threads: 39,018
Posts: 171,143
Top Poster: smasher (2,570)
Welcome to our newest member, iWalter
Powered by vBadvanced CMPS v3.1.0

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