Re: Question about sending to PHP from Obj-C
Re: Question about sending to PHP from Obj-C
- Subject: Re: Question about sending to PHP from Obj-C
- From: Joe Wollard <email@hidden>
- Date: Thu, 04 Aug 2011 10:44:37 -0400
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/occ/instm/NSString/writeToURL:atomically:encoding:error:
I'd guess that you could create an NSURL object with the full GET string, then write an empty string to that url. Something like this completely off-the-cuff code:
NSURL *url = [NSURL URLWithString:@"http://eric.domain.com/iOS_Log/logger.php?string=Foo"];
NSString *emptyString = @"";
[emptyString writeToURL:url atomically:NO encoding:NSUTF8StringEncoding error:NULL];
...come to think of it, since you're doing a GET you could probably just readFromURL and then discard the resulting NSString object. The point is basically that all of your data is going to be in the NSURL for the GET request, all you need to do is "touch" that URL via some method.
On Aug 4, 2011, at 9:52 AM, Eric E. Dolecki wrote:
> I have a little script sitting locally on my Mac (webserver).
>
> http://eric.domain.com/iOS_Log/logger.php:
>
> <?
> $myFile = "yabba.txt";
> $fh = fopen($myFile,'a') or die("can't open file");
> $query = $_GET["string"];
> $stringData = $query."\n";
> fwrite($fh,$stringData);
> fclose($fh);
> ?>
>
> I am simply trying to send the PHP a small string from my app on a device.
> I've seen examples of POST everywhere, but looking for GET.
>
> Of course if I do *http://eric.domain.com/iOS_Log/logger.php?string=Foo* in
> a browser it works fine.
> _______________________________________________
>
> 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
_______________________________________________
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