Wordpress Blog iPhone App Reader [closed]

2019-02-02 01:45发布

问题:

I have a wordpress blog that's sort of a quote of the day type of a deal and I am looking to make a simple iPhone app that automatically downloads the blog content (think RSS—kind of). I want my readers to be able to save their favorite posts and I need to be able to show access to all archives (about 440 posts to date). I also need it to send a push notification when a new post is detected. Anyway, I have been looking at RSS feeds, but it looks like I can only show the last ten.

As far as iPhone programming experience, I'm by no means a noobie. However, I have mostly worked on game projects and I don't have very much experience with the internet side of programming (downloading, parsing, etc.).

Any ideas would be appreciated. I just need to be pointed in the right direction.

回答1:

Here's what I would do, though I'm sure there are many solutions:

  • Get access to your WP blog as JSON instead of RSS (XML). In general, I've found the JSON libs to be much easier to work with than the XML libs in iOS. Here's the first plugin I came across, and it looks like it's an "API" instead of just a conversion of the feed. Hopefully this will give you more support for querying things like archives or specific posts or date ranges, etc.: http://wordpress.org/extend/plugins/json-api/

  • Decide if you want to load ALL content from each wp post, or just the titles. This kinda depends on how big each post is, how you're displaying them, etc. It might be quicker to just fetch + parse all the Post Titles and then make a subsequent query for a selected post's content.

  • Load the data with NSMutableURLRequest and NSURLConnection, etc. Use the json-framework to parse this data, once you get it into your app (I found it through the Stanford iOS dev lectures). Quite easily converts a json string into a NSDictionary: https://github.com/stig/json-framework/

  • As for loading all archives, ideally you can continually query for older posts with your wp json plugin, and maybe store the loaded post's timestamps on the device so that you don't need to fetch data more than once.

  • As for saving all this (including favorites), I'd look into using CoreData. http://developer.apple.com/library/ios/#documentation/DataManagement/Conceptual/iPhoneCoreData01/Introduction/Introduction.html

  • Push notifications are another beast entirely! I suppose the best approach would be to store push tokens of all your 'subscribers' somewhere on your server, then write some kind of php script that triggered your APNS service on an interval, checked for new posts, and sent out notifications accordingly.

Best of luck!



回答2:

TouchJSON has native XML parsing support for Wordpress Blog RSS format. Try it out. You should be up and running in about an hour.

You can get TouchJSON from here https://github.com/TouchCode/TouchJSON