IPhone: sending data to php page

Despite the fact that you are viewing similar messages on this site and on Google, I just can’t turn my head around how to publish messages on a php page from the iPhone. Here is what I want to do:

I have a php script, say on www.mypage.com/myscript.php, that I could publish, usually by doing www.mypage.com/myscript.php?mynumber=99&myname=codezy

This, in turn, will add a log message to the database, for example. I do not want the data to be returned, it is essentially a one-way transaction. NSMutableURLRequest looks like what I'm looking for, but I just can't figure out how to make this work with parameter pairs.

+3
source share
1 answer

URL- , NSURLRequest . , , URL-, . URL- , NSURL.

, , - . , . NSURLConnection.

NSURL *urlToSend = [[NSURL alloc] initWithString: @"www.mypage.com/myscript.php?mynumber=99&myname=codezy"];

NSURLRequest *urlRequest = [NSURLRequest requestWithURL:urlToSend   
                                            cachePolicy:NSURLRequestReturnCacheDataElseLoad                                               
                                   cachetimeoutInterval:30];

NSData *urlData;
NSURLResponse *response;
NSError *error;
urlData = [NSURLConnection sendSynchronousRequest:urlRequest  
                                returningResponse:&response 
                                            error:&error];
+6

Source: https://habr.com/ru/post/1714368/


All Articles