&tag(Twitter, TwitterAPI, SearchAPI, XAuthTwitterEngine);
*目次 [#m766495d]
#contents

*参考情報 [#a8a10a58]

※本家[[MGTwitterEngine]]がxAuth対応しているのでそちらを使った方がよさそうです(2010/08/09)

-[[Aral Balkan · xAuthTwitterEngine library and demo:http://aralbalkan.com/3133]]…解説。
-[[MGTwitterEngineを使ってラクラクTwitter連携 - Tomute’s Notes:http://d.hatena.ne.jp/tomute/20091029/1256865402]]…xAuth以外はMGTwitterEngineなので。
-[[2010-07-25 - yuum3のお仕事日記 (twitterIDは@yuumi3です):http://d.hatena.ne.jp/yuum3/20100725]]
*ダウンロード [#n8d2856a]
-次のURLからダウンロード可能。http://github.com/aral/XAuthTwitterEngine
 git clone http://github.com/aral/XAuthTwitterEngine.git

*プロジェクトの作成 [#td9d68f6]
**概要 [#m72d0797]
-ダウンロードしてきたXAuthTwitterEngineの「Libraries & Headers」の中だけ必要。
-libxmlを使うための設定が必要。
-追加→既存の項目で階層ごとまるごと取り込むだけでよい。YAJLParser関連のエラーがでるのでそれはビルドターゲットから外すか、yajlライブラリを追加してエラーがでないようにする(yajlライブラリがないとSearch APIが動かないっぽい)。
-OAuthConsumer部分はlibOuth.aというライブラリになっておりヘッダーファイルしか存在しない。
**libxmlの設定 [#p08fdfdb]
-ヘッダ検索パスに追加
 $SDKROOT/usr/include/libxml2
-ライブラリの追加。フレームワークの追加メニューからlibxml2.dylibをプロジェクトに追加。

**YAJLParser関連をビルドターゲットから外す場合 [#v2af02a4]
-ターゲット→ソースをコンパイルからエラーになるファイルを探して除外する(一回ビルドしてみるとわかる)。

**YAJLParser関連を使いたい場合 [#v20bd884]
-[[JSONライブラリのYAJLを使ってみる - Tomute’s Notes:http://d.hatena.ne.jp/tomute/20091220/1261372045]]
-[[Setting up MGTwitterEngine with YAJL 1.0.6 for iPhone development | $tail -f damien.mind:http://damienh.org/2009/06/20/setting-up-mgtwitterengine-with-yajl-106-for-iphone-development/]]

などをを参考にしつつ導入。
***ダウンロード [#h6e2e699]
http://github.com/gabriel/yajl-objc/downloadsからiPhone用のzipファイルをダウンロード。
***プロジェクトに追加 [#z1a61303]
ダウンロードした中身のヘッダーファイルとライブラリファイルを追加。yajl/xxx.hという形でインクルードしているのでyajlというディレクトリを作ってその親ディレクトリをインクルードパスに追加しないとだめだった。
***ヘッダーファイルの修正 [#t4443f31]
MGTwitterEngineGlobalHeader.hを修正。
 #define YAJL_AVAILABLE 1
***ソースファイルの修正 [#j42a013d]
コンパイルエラーがでる。
#pre{{
_handle = yajl_alloc(&callbacks, &cfg, nil, self);

yajl_free_error(nil, errorMessage);
}}



***完成 [#od786bd7]
コンパイルしてエラーがでなければ完成。

*サンプル [#qaa36156]
**検索 [#d6b6d391]
[[Parsing Search Result with MGTwitterEngine in Objective C - Stack Overflow:http://stackoverflow.com/questions/1851214/parsing-search-result-with-mgtwitterengine-in-objective-c]]によると、呼び出し
 [myTwitterEngine getSearchResultsForQuery:@"#joke" sinceID:0 startingAtPage:1 count:5]);
結果を受ける
#pre{{
- (void)searchResultsReceived:(NSArray *)searchResults 
                   forRequest:(NSString *)connectionIdentifier
{
    if ([searchResults count] > 0)
    {
        NSDictionary *result = [searchResults objectAtIndex:0];

        NSString *fromUser = [result valueForKey:@"from_user"];
        NSString *fromUserID = [result valueForKey:@"from_user_id"];
        // ...
        NSString *text = [result valueForKey:@"text"];

        NSLog(@"User %@(%@): %@", fromUser, fromUserID, text);
    }
}
}}

-うまくいくかと思ったら、だめだった_| ̄|○ il||li
-[[Twitter / Nozomu Miura: MGTwitterSearchYAJLParser. ...:http://twitter.com/z37soft/status/11465404892]]


トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS