Thursday, November 11, 2010

Using PHP with the Iphone


Using PHP with the Iphone

So after a lot of researching and looking around at alternatives to directly connecting to a mysql database through objective c, ive stumbled across a different approach. Instead of having the iphone connect to the database and run all the queries and what no itself, it would make more sense for the iphone to just hit a php script out on the web somewhere. Ive found two articles that describe this some what.

http://idevkit.com/forums/tutorials-code-samples-sdk/28-easily-interface-server-php-anything-else.html

http://developer.apple.com/internet/webservices/webservicescoreandcfnetwork.html

The basic idea is to have objective c simply send an http request with specefic header information to a designated url for different operations. So for example, if the iphone wants to grab all of the information about a certain user named joe123, it could simply send a request to

www.somewhatwebsite.com/user.php?user=joew123

then the php would do the query of the database and return an xml formatted profile of joe123. the only drawback to this approach is that if we do all of our queries this way, then someone could go in and screw up the whole database if they knew the urls. for example, if a function reset a field in the database, someone could just write a script to hit that function all day long. the positive note to this approach is that all of the main functionality and stress of the application isnt really done on the iphone at all. instead it would be done by the webserver. all the iphone would do is simply send requests and receive and parse in xml data. in the next day or so, ill hopefully have a working example of this....

No comments:

Post a Comment

Followers