Obtaining information from Webpage - displaying it in an Iphone app - iphone

Is it possible to pull information from a website and display it in an iphone application?
I am looking to pull the current temperature and barometric pressure for an airport from the http://adds.aviationweather.noaa.gov website and display those two pieces of information in an app.
This sounds like a common task that programs do all the time but I'm not sure how it's incorporated into an app.. (what is the process of pulling webdata called?)
What methods or tools are available to do this? I am unfamiliar with handling web data for iphone at this time.

If they have an actual feed for the data, you could access it using NSHTTPRequest and parse the results.
If you need to screen-scrape the data off the page itself, then I would highly suggest creating your own web service to do the parsing and have your iPhone app talk to your web service. The reason being that if they update the page in a way that breaks your screen scraping you would only have to update your web service instead of deploying an update out to who-knows-how-many iPhones.

Just use an NSHTTPRequest and all the related classes to assemble a standard HTTP GET request for the site with the data you need. If there's a data feed (XML, JSON, etc.), you should find out what that URL is and use it instead of parsing the actual HTML of the web page. If not, the method is called "screen scraping" and it basically involves you writing a regular expression to parse the HTML of the web page returned from the server. Again, don't do this unless there is no alternative data feed you can use.
If you need to parse XML, see NSXMLParser. There are open-source solutions for parsing JSON in Objective-C. Just Google around for them.

Related

How do I update the content of my app without releasing another version?

I have an app that basically has news and updates about a certain subject. How do I get it to work that when I update something let's say in my website it would also update what's on the app. Do I usee RSS for this?
You need some web service to deliver the data. In terms of what format a web service can use, there are a variety, but two prevalent formats are XML and JSON. RSS is, essentially, a particular form of XML.
On the iOS side, you can parse XML using NSXMLParser (see NSXML Parser Class Reference). If you're parsing JSON, you can use NSJSONSerialization (see NSJSONSerialization Class Referece). For both of these, you can google the class keyword followed by "example" or "demonstration" (e.g., "NSXMLParser example" or "NSJSONSerialization demonstration") and you'll see tons of examples. If you have an RSS feed, you can google something like "iOS RSS example".
It may be dictated by what you can easily render from your server, XML (or, in particular, RSS) or JSON. For example, if you're using some content management system on your web site, it might offer RSS feeds, or something like that. In the absence of that, you may have to write your own server interface to retrieve the data in XML (or RSS) or JSON formats.
In addition to #Rob answer I would point couple mode things:
You can simply prepare databases with your information (like SQLite) and just download them from your web site to your application.
You need to have some way of notifying application about new content and for that you might want to use remote notifications. http://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/IPhoneOSClientImp/IPhoneOSClientImp.html - this way you can send notify messages to your app, and user will know that there is something new to download and read.

How to create a news like iPhone app that updates weekly

I have created a few small apps for the iPhone so I have some experience. An organization that I'm in asked me if I could program a weekly newsletter app for them. I though it would be a good challenge so I agreed. My question is: how do I get the app to update weekly without the users having to re-download or manually update? Do I connect to a database or a website? Can anyone send me the link to a good tutorial? I wasn't able to find one.
Thank you!
Your question is very general but I could give you some suggestions.
First, you need to connect to a service that provides you news info. This is needed. The service could send you an xml that you can parse and display, for example in a UITableView. XML is not the only solution. You could use also JSON.
For parsing XML I suggest you to read GDataXML, while for JSON JSONKit framework. But there are also other valid framework out there.
Then, to save data it depends on what kind of data you deal with. Here you could find different ways to save your news. Save an XML that contains your news, serialize data and save them in the local filesystem or use Core-Data.
To update your news without user actions, you have to save the last time when the app has downloaded news (for example in NSUserDefaults) and each time time the application is "activated" check for that date and update news if necessary.
Out there there are plenty of tutorials on how to (in parenthesis I inserted classes or framework that you could have a look):
consuming web service on iPhone (ASIHttpRequest - no more supported, NSURLConnection class, AFNetworking)
dealing with XML file/data and theirs parsing (GDataXML, touchXML, etc.)
dealing with JSON messages (JSONKit, etc.)
managing documents (NSFileManager class)
using Core-Data
using Property-List and/or NSUserDefaults
First three cover the first step (download). Other three cover the second one (save). Obviously you have not to use all of them. For example a configuration could be:
NSURLConnection for service, GDataXML for parsing XML data and Property-List for save data.
Hope it helps.
A simpler approach would be to make it a pure web app and update the website weekly.
Your content providers are going to have to do those updates anyway.
Check: Adding Newsstand Support to Your App or Tutorial: How To Make Your App Work With The Newsstand

Displaying Server Side Content in iOS app - Approach Needed

First, Thanks for your help - I greatly appreciate it. The core solution I am trying to figure out is how to display content from a CMS inside of an iOS application. The application I am planning is a company intranet / portal used to display news, alerts, and other content to sales associates at our firm. One approach a friend suggested as build the content in HTML and display in a web view, This does not sound like the best solution too me. How do apps like Facebook, Flipboard, etc display server side content inside the applications.
The application / employee portal will consist of news stories, alerts, documents etc in text form accompanied by images, video, audio. The sales associates will use the application to navigate through the content stories, read, review, etc with all of the nice features of ios, the sliding and flipping of pages and content, etc.
The content and user roles would be managed by a CMS (Joomla, SharePoint, Storage Room, If you know of something better please let me know). The app content would also need to be accessible when offline, what is the best approach for this solution? Is there any existing code bases / libraries that I could leverage for this?
I am having trouble understanding the best process for 1) rendering / displaying the CMS content inside the the App (HTML webview or Another approach?) and 2) How do pull the content, images, video, audio down to the device for offline viewing?
Any ideas you might have will help. If you think there is a starting point set of code, or an example model we might be able to use as a starting point, please let me know.
Thanks You! I greatly appreciate any input.
This is all possible for ios app. you have to made web service for your apps. At the starting when an app is start the data are store in local database like used sqlite or core data in your app. so after that if there is no internet you can stil access your data.
A framework/product like TapLynx or Appcelerator might be a good fit for you. Look at the product demos and showcased apps to see whether they support the kind of thing you want to do.
HTML webviews are a good mechanism for displaying rich content on the device. As to whether you'll display HTML which exists in the CMS, or pull down data and format the HTML on the device, it's really up to you.
I'd go about it creating an API on the server. You can download the data as raw XML or json and parse that content into workable objects. As for how to download pictures and other data, just include the URL string for the picture in the XML / json download.
See the iOS downloading programming guide for details on how to do download data from a server.
Also, as hiren said, you can save the downloaded data using core data.

Parsing Injected Web Page Data

Trying to create an iPhone app (Objective-C) for my school. I want it to search for, and then parse any emergency announcements on the web page. They do not occur in the HTML, and are probably written in with PHP or another server-sire language. Any way i can access that information? (Link: http://www.ridgefield.org/)
I recommend that you parse http://www.ridgefield.org/ajax/dist/emergency-announcements as this is the address where the website fetches the info.
Next time you could use the Firefox plugin Tamper Data found at https://addons.mozilla.org/en-US/firefox/addon/tamper-data/. Try it out!

load videos to play on iPhone from MySQL using php Webservice

Can any one please guide me on this . I am new to iphone/ipad programming.I store videos on my webserver (apache/php).I need to write code for an ipad app to get the videos list for a selected user and play those videos on the ipad/iphone using a php webservice.I was not able to get going on this.Please can anybody share any related links or shower your thoughts on this ? Any help would be highly appreciated.
Thanks
your question actually involves a lot to implement, but I'm not sure where you're right now:
Sever-side programming to expose web-service which can be invoked to
get a list of available videos. Have you done this? And what format
your server-side responses, SOAP XML or JSON?
From your iOS client side, you firstly need to establish an HTTP
request to the web-service URL entry. Have you done that? You may
want to use ASIHTTPRequest to save your effort.
Once you've got server response, depending on how the data is
presented, you may need to find a XML parser or a JSON parser to
parse the raw response.
Then you need to either download the video entirely before playback,
or stream the playback. You may again need ASIHTTPRequest for
downloading. You may need MPMoviePlayerViewController or
MPMoviePlayerController(if you want more control over the player layout) to plackback/stream the video, see:
MPMoviePlayerController and HTTP Live Streaming
And don't forget to save the playlist and user viewing history if
you want to provide a smooth user experience. You may use as simple
as NSUserDefaults/plist as the data persistence media, or as complex
as SQLite database or Core Data.
I suggest you to break down your ultimate goal into specific tasks, and tackle them one by one.
Program your web server to return a JSON object with the list of
movies. You can include preview thumbnails etc.
Include one of the JSON frameworks available (just do a quick
search, there are plenty).
Use the data from the JSON feed to display your list.
When the user clicks on an item, launch a view controller with a
UIWebView to display your movies.
If you do not know how to do any of these things, you should consider an objective-C programming tutorial first.