开发者

Server setup for basic forum-style app on iPhone?

开发者 https://www.devze.com 2023-01-22 23:20 出处:网络
I\'m not really a server-side person – I generally do iPhone apps, though I\'ve hacked together a few Wordpress sites.

I'm not really a server-side person – I generally do iPhone apps, though I've hacked together a few Wordpress sites.

I'm curious as to what web technologies people would use for the back-end of an iPhone app whose front end presents as a basic forum. In other words, people can create开发者_如何学JAVA new threads, and respond to them - with plain text only.

The forum would not exist as a website.. the only way to access it would be on the phone.

What technology would people recommend I use? Ruby-on-Rails with Amazon S3 storage? Could I even use existing forum software and pass and receive data to and from it? Perhaps even a forum Wordpress plug-in? Or is there a better way?


If you wanted to, you could use existing forum software and/or Wordpress to facilitate what you want, which would be easier than building your own forum from scratch. You could, with that existing framework, set up your own little API to communicate from the iPhone app to the server- for example, send a $_GET request to a PHP script on your server, which would return a list of forum topics. You could have similar PHP scripts that could do similiar functions, like adding a post or deleting topics.

That's pretty much how I've got it set up on an iPhone app I recently made- my server has a basic forum system, and I just wrote a couple of PHP scripts to return information from a MySQL server. However, if you'd particularly prefer to use Wordpress/Amazon S3/whatever else, then I could give more specific instructions relating to those services.

*EDIT*

Here's an example PHP script you could use (after you've created databases):

forumcategories.php

<?php
// insert database connecting logic here

$query = mysql_query("SELECT * from categories");

echo "<categories">;

while($row=mysql_fetch_array($query)){
echo "<category><id>" . $row['id'] . "</id><title>" . $row['title']; . "</title></category>;"

}
echo "</categories>";

?>

This is a really simple script- of course, you would need to add in code to connect to the database (which can be found easily online) and probably some error checking, but other than that, it will do the trick. What you would do in the iPhone app is send a request to http://yourserver/forumcategories.php and it would return XML listing all of the categories, which can easily be parsed with NSXMLParser and placed into a UITableView, for example.


Google App Engine is very good for what you describe. There are a lot of advantages to this approach: choice between Java and Python, access to the Google Accounts API, persistence/datastore APIs,... and you don't have to setup much to start working.

I also recommend that your server app returns responses formatted according to Apple's XML Property List format, instead of any other XML or JSON format. You can avoid NSXMLParser (or any other parser) altogether and save time to use on other important stuff.

0

精彩评论

暂无评论...
验证码 换一张
取 消