coderjoe
coderjoe

Reputation: 147

Send data to server with GET

I have made a site where all my highscores from my game are shown. I send the scores from my iphone game to my site using a script made with php. The script works, because if I enter the link produced by my app in my browser the score is added.

However I want to send the scores from my app. The script is using the GET method to get name, scores etcetera.

This is what i have now:

 NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:urlString]];
NSError * e;
NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:&e];

But it's not sending data to my server. The urlString is correct, because if I enter the link produced by my app in my browser the score is added.

How can i solve this problem,

Thanks in advance

Upvotes: 0

Views: 189

Answers (1)

Jelle
Jelle

Reputation: 1034

Do you check if the url has invalid characters? When you paste the url in a browser, spaces and other funnies are converted to url encoded values by the browser. You might need to url encode your urlString to get the desired response.

Search for this NSString method: stringByAddingPercentEscapesUsingEncoding: and use NSUTF8StringEncoding as parameter.

Upvotes: 1

Related Questions