How to get data from a web service? - ios

I'm trying to write an iOS application that'll get data from a web server and display it as I want. I want to use JSON for this purpose. But as I'm absolutely new to web apps I've got no idea how I'm going to get the url to a certain feed. Now here're the two big questions:
How do I find the url to a feed provided by a web service? Is there a standard way or is it publicly or exclusively handed to the web service subscribers?
Is the format they provide data in up to their preference (like XML or JSON)? I mean, do I choose my data parsing method according to the format the web service gives data in? So that if the feed is in XML format using NSJSONSerialization class makes no sense.

The URL to use is dependent on the web service and is usually well described in the documentation.
The type of data they return and the the structure is also usually well described in the documentation.
The common bits you'll need to know are how to get to the web-service (NSURLRequest/NSURLConnection or any of the many asynchronous wrappers that are open source and available with a bit of searching), And how to deal with the the returned data - whether it's in JSON (NSJSONSerialization, JSONKit) format or XML (NSXMLParser, libxml, or any of the many open source implementations that are available and described with a bit of searching)

Related

Parse and store using Apache Nutch

I am trying to develop a Crawler to crawl youtube.com and parse the meta information(title, description, publisher etc) and store these into Hbase/other storage systems. I understood that I have to write plugin(s) to achieve this. But I'm confused what plugins I need to write for this. I am inspecting with this four -
Parser
ParserFilter
Indexer
IndexFilter
To parse the specific metadata information for youtube page, do I need to write a custom Parser plugin or ParseFilter plugin along with using parse-html plugin?
After parsing, to store the entry in Hbase/other storage system do I require to write a IndexWriter plugin? By indexing, we generally understand indexing in Solr, ElasticSearch etc. But I don't need to index in any search engine obviously. So, how can I store them in some store say Hbase after parsing?
Thanks in advance!
Since youtube is a web page, you'll need to write an HtmlParseFilter which gives you access to the raw HTML fetched from the server, but at the moment youtube a LOT of javascript and neither parse-html or parse-tika support executing the js code, so I'll advice you to use the protocol-selenium plugin so you'll delegate the rendering of a webpage to the selenium driver and get the HTML back (after all the JS has been executed). After you write your own HtmlParseFilter you'll need to write your own IndexingFilter, in this case you'll only need to specify what info you want to send to your backend, this is totally backend-agnostic and relies only on the Nutch codebase (that's why you'll need your own IndexWriter).
I assume that you're using Nutch 1.x, in this case yes you need to write a custom IndexWriter for your backend (which is fairly easy). If you use Nutch 2.x you'll have access to several backends through Apache Gora but then you'll have some features missing (like protocol-selenium).
I think you should use something like Crawler4j for your purposes.
The real power of Nutch is utilized when you want to do a much wider search or you want to index your data directly into Solr/ES. But since you just want to download data for each URL, I would totally go with Crawler4j. It's much easier to setup and does not require complex configurations.

How to parse GTFS data on iOS using swift?

I am using http://datamine.mta.info/list-of-feeds api to get GTFS data for United States transportation.
When you call http://datamine.mta.info/mta_esi.php?key=<key>&feed_id=1 api you get one "gtfs" file which contains data that I need to parse in iOS so that I can display.
Once I get the file, how do I parse it? So far I haven't found a way to do so. Anyone can help me on this?
Thanks,
Pratik
The MTA requires that you serve the realtime data from your own server, so you might as well parse the Protocol Buffers server-side, and then make your data available to your iOS app from your server. If you do it that way, then you can use e.g., a Python or C++ library to parse the PB into JSON or whatever and structure it in an optimal way for your app for download.

String saved in IOS app, accessible from web browser. Best method?

As the title says, I'm looking for a string to be input in an IOS app and stored in a way that it would be accessible from a web browser.
Both editable and readable from web and the app.
From initial googling, I've come across Dropbox Datastore API but it is being deprecated.
What would be a good alternative for this?
Your intentions are quite scant. However, I assume you want a little more than just reading and writing a string. Inferring a bit more context, you should look at Apple's CloudKit.
It has API for iOS, OS X, and apparently now javascript. See this link for more details.
You need some code running on a server and a database to save the string, with an API to access this string from a client.
FireBase is probably the simplest drop in solution since it gives you a very basic example and a web based UI for testing (plus it updates in realtime)

JQX Grid server data response example

I'm trying to implement a jqxGrid, using sorting and paging on the server. I don't have access to the server itself. Taking an example from:
http://www.jqwidgets.com/jquery-widgets-documentation/documentation/phpintegration/php-server-side-grid-paging-and-sorting.htm
I implement the client-side and want to use a mock static file as a response. I can't manage to figure out what kind of JSON response format is meant to be returned.
How do I 'catch' and edit/format the JSON response from the server? (Where in the code?)
Is there anywhere a working example of a jqgrid with sorting done on the server, to be viewable online? (So I can observe the data structure returned).
What do you mean exactly? Do you want to edit the data itself or the view of the data? If it is the later one you can use cellsrendered. For a live demo look here. You can also change the value here since you have access to the value field but it is by column.
Yes, look here.
http://www.jqwidgets.com/jquery-widgets-documentation/
You can find there information about the datasource.
http://www.jqwidgets.com/jquery-widgets-documentation/
You can find there (right menu):
PHP Integration
ASP.NET Integration
You can find there what ever yo need (sorting filtering and so)

Was it able to retrieve data from a external web site which does not provide a API using YQL?

I'd like to retrieve data from a web site ,which does not provide a API
Can I retrieve data using YQL?
ie: Can I custom the data parse in the target URI with YQL?
Yes, you can. This is one of the most popular use case of YQL. Here is a sample. But it is not working when trying to retrieve data from web-page which is dissallowed for spider access (via robots.txt, for example).
Without knowing what you're trying to do, the only reasonable answer here is…
Yes.

Resources