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

Get gorgeous, multi-touch charts for your iOS application with just a few lines of code.

"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.

 

.Net developers: use Highcharts, the industry's leading interactive charting library, without writing a single line of JavaScript.

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 DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

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

X

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

{{ parent.tldr }}

{{ parent.urlSource.name }}