Twitter-OAuth-iPhone
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
&tag(Twitter-OAuth-iPhone);
*目次 [#tf833dcf]
#contents
*参考情報 [#s34a9dab]
-[[bengottlieb/Twitter-OAuth-iPhone · GitHub:https:/...
*デモプロジェクトのビルド [#b2aeb473]
-zipをダウンロードして展開。Demoフォルダの下にプロジェク...
-OAuthTwitterDemoViewController.mのConsumerKeyとConsumerS...
#pre{{
#define kOAuthConsumerKey @"" //REPLACE ME
#define kOAuthConsumerSecret @"" //REPLACE ME
}}
**トラブルシューティング [#j72d11fa]
*** "Select and Copy the PIN"って何? [#m52c43f2]
-callbackurlがセットされてるとうまくいかないのかも。
-[[Issue for Twitter applications with callback URL set &...
#pre{{
- (void) webViewDidFinishLoad: (UIWebView *) webView {
_loading = NO;
//[self performInjection];
if (_firstLoad) {
[_webView performSelector: @selector(stringByEval...
_firstLoad = NO;
} else {
// This else clause modified to work with twitter...
// Bug details: https://github.com/bengottlieb/Tw...
[_engine requestAccessToken];
if ([_delegate respondsToSelector: @selector(OAut...
[_delegate OAuthTwitterController: self authe...
[self dismissModalViewControllerAnimated:YES];
}
[UIView beginAnimations: nil context: nil];
_blockerView.alpha = 0.0;
[UIView commitAnimations];
if ([_webView isLoading]) {
_webView.alpha = 0.0;
} else {
_webView.alpha = 1.0;
}
}
}}
***GETでパラメータがセットされてない [#d15b26da]
-[[SA_OAuthTwitterEngine _sendRequestWithMethod:.... fail...
-以下のように修正。
#pre{{
if (!method && params) {
fullPath = [self _queryStringWithBase:fullPath pa...
}
}}
*デモプロジェクトの仕組み [#wa6a5550]
**起動時 [#s072c155]
-OAuthTwitterDemoViewControllerのviewDidApperから開始。co...
#pre{{
UIViewController *controller = [SA_OAuthTwitterControl...
if (controller)
[self presentModalViewController: controller animated: ...
else {
[_engine sendUpdate: [NSString stringWithFormat: @"Alre...
}
}}
-SA_OAuthTwitterControllerのcontrollerToEnterCredentialsW...
#pre{{
- (BOOL) isAuthorized {
if (_accessToken.key && _accessToken.secret) return YES;
//first, check for cached creds
NSString *accessTokenString = [_delegate respondsToS...
if (accessTokenString.length) {
[_accessToken release];
_accessToken = [[OAToken alloc] initWithHTTPResponseBod...
[self setUsername: [self extractUsernameFromHTTPBody: a...
if (_accessToken.key && _accessToken.secret) return YES;
}
[_accessToken release]; // no access token foun...
_accessToken = [[OAToken alloc] initWithKey: nil secret:...
return NO;
}
}}
-OAuthTwitterDemoViewControllerのcachedTwitterOAuthDataFo...
oauth_token=xxxxxxxxxxx&oauth_token_secret=yyyyyyyyyyyyy...
-とりだしたデータからOATokenをアロケートし保存。リクエス...
**認証実証時 [#l3ad4f6f]
-SA_OAuthTwitterEngine.mのsetAccessToken:withData:が呼び...
#pre{{
- (void) setAccessToken: (OAServiceTicket *) ticket withD...
if (!ticket.didSucceed || !data) return;
NSString *dataString = [[[NSString alloc] initWithData: ...
if (!dataString) return;
if (self.pin.length && [dataString rangeOfString: @"oaut...
NSString *username = [self extractUsernameFromHTTPBod...
if (username.length > 0) {
[self setUsername: username password: nil];
if ([_delegate respondsToSelector: @selector(storeCache...
}
[_accessToken release];
_accessToken = [[OAToken alloc] initWithHTTPResponseBody...
}
}}
-ちなみに、username(=@xxxxで使われるscreen_name)は以下の...
#pre{{
- (NSString *) extractUsernameFromHTTPBody: (NSString *) ...
if (!body) return nil;
NSArray *tuples = [body componentsSeparatedByString:...
if (tuples.count < 1) return nil;
for (NSString *tuple in tuples) {
NSArray *keyValueArray = [tuple componentsSeparatedBySt...
if (keyValueArray.count == 2) {
NSString *key = [keyValueArray objectAtIndex: 0];
NSString *value = [keyValueArray objectAtIndex: 1];
if ([key isEqualToString:@"screen_name"]) return value;
}
}
return nil;
}
}}
終了行:
&tag(Twitter-OAuth-iPhone);
*目次 [#tf833dcf]
#contents
*参考情報 [#s34a9dab]
-[[bengottlieb/Twitter-OAuth-iPhone · GitHub:https:/...
*デモプロジェクトのビルド [#b2aeb473]
-zipをダウンロードして展開。Demoフォルダの下にプロジェク...
-OAuthTwitterDemoViewController.mのConsumerKeyとConsumerS...
#pre{{
#define kOAuthConsumerKey @"" //REPLACE ME
#define kOAuthConsumerSecret @"" //REPLACE ME
}}
**トラブルシューティング [#j72d11fa]
*** "Select and Copy the PIN"って何? [#m52c43f2]
-callbackurlがセットされてるとうまくいかないのかも。
-[[Issue for Twitter applications with callback URL set &...
#pre{{
- (void) webViewDidFinishLoad: (UIWebView *) webView {
_loading = NO;
//[self performInjection];
if (_firstLoad) {
[_webView performSelector: @selector(stringByEval...
_firstLoad = NO;
} else {
// This else clause modified to work with twitter...
// Bug details: https://github.com/bengottlieb/Tw...
[_engine requestAccessToken];
if ([_delegate respondsToSelector: @selector(OAut...
[_delegate OAuthTwitterController: self authe...
[self dismissModalViewControllerAnimated:YES];
}
[UIView beginAnimations: nil context: nil];
_blockerView.alpha = 0.0;
[UIView commitAnimations];
if ([_webView isLoading]) {
_webView.alpha = 0.0;
} else {
_webView.alpha = 1.0;
}
}
}}
***GETでパラメータがセットされてない [#d15b26da]
-[[SA_OAuthTwitterEngine _sendRequestWithMethod:.... fail...
-以下のように修正。
#pre{{
if (!method && params) {
fullPath = [self _queryStringWithBase:fullPath pa...
}
}}
*デモプロジェクトの仕組み [#wa6a5550]
**起動時 [#s072c155]
-OAuthTwitterDemoViewControllerのviewDidApperから開始。co...
#pre{{
UIViewController *controller = [SA_OAuthTwitterControl...
if (controller)
[self presentModalViewController: controller animated: ...
else {
[_engine sendUpdate: [NSString stringWithFormat: @"Alre...
}
}}
-SA_OAuthTwitterControllerのcontrollerToEnterCredentialsW...
#pre{{
- (BOOL) isAuthorized {
if (_accessToken.key && _accessToken.secret) return YES;
//first, check for cached creds
NSString *accessTokenString = [_delegate respondsToS...
if (accessTokenString.length) {
[_accessToken release];
_accessToken = [[OAToken alloc] initWithHTTPResponseBod...
[self setUsername: [self extractUsernameFromHTTPBody: a...
if (_accessToken.key && _accessToken.secret) return YES;
}
[_accessToken release]; // no access token foun...
_accessToken = [[OAToken alloc] initWithKey: nil secret:...
return NO;
}
}}
-OAuthTwitterDemoViewControllerのcachedTwitterOAuthDataFo...
oauth_token=xxxxxxxxxxx&oauth_token_secret=yyyyyyyyyyyyy...
-とりだしたデータからOATokenをアロケートし保存。リクエス...
**認証実証時 [#l3ad4f6f]
-SA_OAuthTwitterEngine.mのsetAccessToken:withData:が呼び...
#pre{{
- (void) setAccessToken: (OAServiceTicket *) ticket withD...
if (!ticket.didSucceed || !data) return;
NSString *dataString = [[[NSString alloc] initWithData: ...
if (!dataString) return;
if (self.pin.length && [dataString rangeOfString: @"oaut...
NSString *username = [self extractUsernameFromHTTPBod...
if (username.length > 0) {
[self setUsername: username password: nil];
if ([_delegate respondsToSelector: @selector(storeCache...
}
[_accessToken release];
_accessToken = [[OAToken alloc] initWithHTTPResponseBody...
}
}}
-ちなみに、username(=@xxxxで使われるscreen_name)は以下の...
#pre{{
- (NSString *) extractUsernameFromHTTPBody: (NSString *) ...
if (!body) return nil;
NSArray *tuples = [body componentsSeparatedByString:...
if (tuples.count < 1) return nil;
for (NSString *tuple in tuples) {
NSArray *keyValueArray = [tuple componentsSeparatedBySt...
if (keyValueArray.count == 2) {
NSString *key = [keyValueArray objectAtIndex: 0];
NSString *value = [keyValueArray objectAtIndex: 1];
if ([key isEqualToString:@"screen_name"]) return value;
}
}
return nil;
}
}}
ページ名: