2013年1月26日 星期六

One API per Day to use WordKit APIs on iOS

WordKit iOS API is available for download in http://developer.wordnik.com/libraries/wordkit-ios-sdk

I used iOS package from Github https://github.com/wordnik/wordkit/tree/master/frameworks/objective-c

This is one of the API in programmableWeb listing. (http://www.programmableweb.com/api/wordnik)

I like use its petstore to test API results. (http://petstore.swagger.wordnik.com/)


--------------
The is the procedure to get the demo running on your iOS app.

1. To get your API key, sign up on this website (http://developer.wordnik.com/) , and you will receive a API Key by email.

2. And download WordKit from Github (https://github.com/wordnik/wordkit), install it dmg on your mac (actually it's just uzip the files, you need to copy framework to your app in Xcode later on).

3. The demo code is under wordkit/frameworks/objective-c/examples/ios, named WNDemoApp. Go that directory and run in Xcode (open *proj).

4. search "YOUR_API_KEY" and replace it with your API key got from developer.wordnik by email.

5. Then run your project. (You may got some warnings and errors.)



(Thanks for help from Erin McKean in https://groups.google.com/forum/?fromgroups=#!topic/wordnik-api/a50xFW52kQQ to fix the problems.)
--------------
1. I got some problem when run it's demo code. (in wordkit/frameworks/objective-c/examples/ios/WNDemoApp directory). But it can resolve with some following steps.

a. add Wordnik.framework and WordnikUI.framework to the demo project.
b. change all files with

#import  <Wordnik/WNAdditions.h>

to

#import "WNAdditions.h"

If it still not working, see this from github

https://github.com/wordnik/wordkit/commit/ec3deb2e509d44a5fcda7e5ecac6bc9573ea99a8

c. as in URL above

you can add a file NSAddition.h to this project with source code as follows

// // WNAdditions.h // WNDemoApp // // Created by Tony Tam on 3/15/11. // Copyright 2011 wordnik. All rights reserved. // #import /** * @ingroup additions_foundation * * Release the provided object and set its pointer value to nil. * * @param obj Object pointer to release and set to nil. */ #define WNNilRelease(obj) {\ [obj release]; \ obj = nil; \ } @interface NSArray (WNAdditions) - (NSArray *)wn_map:(id (^)(id obj))block; @end

To get rid off all compiler warnings.

-------------
demo (I got audio file for the word "Apple")




-----------
for streaming over websocket

refer to (http://blog.wordnik.com/introducing-swaggersocket-a-rest-over-websocket-protocol)

---------- Google groups forum for wordnik API
https://groups.google.com/forum/?fromgroups#!forum/wordnik-api

沒有留言:

張貼留言