Как я могу сделать HTTPResponse в php? У меня возникли некоторые проблемы :( Я должен прочитать ответ от приложения какао. Это мой php код:
<?php
HttpResponse::setCache(true);
HttpResponse::setContentType('text/plain');
HttpResponse::setData("Some data");
HttpResponse::send();
?>
Тогда вот мой код какао:
- (void)viewDidLoad
{
[super viewDidLoad];
[self.view setBackgroundColor:[UIColor whiteColor]];
NSURL *url = [NSURL URLWithString:@"Web site"];
NSURLRequest *theRequest=[NSURLRequest requestWithURL:url
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
// create the connection with the request
// and start loading the data
NSURLConnection *theConnection=[[[NSURLConnection alloc] initWithRequest:theRequest delegate:self] autorelease];
if (theConnection) {
receivedData = [[[NSMutableData data] retain] autorelease];
NSLog(@"OK!");
} else {
NSLog(@":(((");
}
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
// Append the new data to receivedData.
// receivedData is an instance variable declared elsewhere.
NSLog(@"DATA");
NSString* aStr;
aStr = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
NSLog(@"%@",aStr);
}
Но это не работает :( Идеи?