Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Invoking the Insights for Twitter Service in Bluemix from Swift

DZone's Guide to

Invoking the Insights for Twitter Service in Bluemix from Swift

See how you can interact with Bluemix in iOS

· Mobile Zone
Free Resource

Discover how to focus on operators for Reactive Programming and how they are essential to react to data in your application.  Brought to you in partnership with Wakanda

"Hear the Buzz" is a sample iPhone app which finds tweets with positive or negative sentiments for certain topics via the IBM Insights for Twitter service in IBM Bluemix. Below is a short description how this service is used from Swift.

As a starting point I used the sample app from my colleague Frederic Lavigne. The sample contains a simple Node.js application which provides a REST API that basically just forwards requests to the service and adds credentials so that clients can invoke the API without having to authenticate. I used this mechanism in this simple sample but you might want to change this for production apps.

Clients can now invoke REST APIs via insights-search.mybluemix.net/api/1/messages/search?q=bluemix which returns JSON. The following code shows how I parse the JSON is Swift. There might be better ways to do this though. I haven't done much Swift development honestly.


The next screenshot shows the code how to invoke the REST API from Swift. In order to define the tweets I'm interested in I use the query language of the Twitter service.

 

Learn how divergent branches can appear in your repository and how to better understand why they are called “branches".  Brought to you in partnership with Wakanda

Topics:
bluemix ,ios ,swift

Published at DZone with permission of Niklas Heidloff, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}