Twitter REST APIを使用するためのクライアント。カスタムリクエストを作成して送信する機能と同様に、一般的なAPIリクエストを扱うメソッドも用意されています。
継承元 | NSObject |
宣言場所 | TWTRAPIClient.h |
TWTRAPIClient Class ReferenceClient for consuming the Twitter REST API. Provides methods for common API requests, as well as the ability to create and send custom requests.
|
– initWithConsumerKey:consumerSecret:
– URLRequestWithMethod:URL:parameters:error:
– sendTwitterRequest:completion:
– loadUserWithID:completion:
– loadTweetWithID:completion:
– loadTweetsWithIDs:completion:
TasksInitialization
Making Requests
Common API Actions
|
Instance Methods |
署名済みのURLリクエストを戻り値として返します。
- (NSURLRequest *)URLRequestWithMethod:(NSString *)method URL:(NSString *)URLString parameters:(NSDictionary *)parameters error:(NSError **)error
method
GET, POST, PUT, DELETE, などのリクエストメソッド。
parameters
リクエストパラメータ。
error
リクエストの署名でエラーが発生した場合に設定されるエラー。
URL
リクエストURL。これは Twitter APIのフルURLです。 例えば、 https://api.twitter.com/1.1/statuses/user_timeline.json
TWTRAPIClient.h
頭に国コードが付いた、ユーザーから提供された電話番号(例えば +15554443322)。
@property (nonatomic, copy, readonly) NSString *phoneNumber
URLRequestWithMethod:URL:parameters:error:Returns a signed URL request. - (NSURLRequest *)URLRequestWithMethod:(NSString *)method URL:(NSString *)URLString parameters:(NSDictionary *)parameters error:(NSError **)error Parametersmethod Request method, GET, POST, PUT, DELETE, etc. parameters Request parameters. error Error that will be set if there was an error signing the request. URL
Request URL. This is the full Twitter API URL. E.g.
Declared in
The phone number provided by the user, prefixed by the country code (e.g. @property (nonatomic, copy, readonly) NSString *phoneNumber |
Designated initializer.
- (instancetype)initWithConsumerKey:(NSString *)consumerKey consumerSecret:(NSString *)consumerSecret
consumerKey
Twitter アプリケーションのコンシューマキー.
consumerSecret
Twitter アプリケーションのコンシューマ秘密情報。
TWTRAPIClient.h
initWithConsumerKey:consumerSecret:Designated initializer. - (instancetype)initWithConsumerKey:(NSString *)consumerKey consumerSecret:(NSString *)consumerSecret ParametersconsumerKey The consumer key of the Twitter application. consumerSecret The consumer secret of the Twitter application. Declared In
|
ネットワークもしくはキャッシュから、ツイートを一つ読み込む。
- (void)loadTweetWithID:(NSString *)tweetIDString completion:(TWTRLoadTweetCompletion)completion
tweetIDString
読み込むツイートのID。
completion
応答時に呼び出されるCompletion ブロック。メインキューで呼び出されます。
TWTRAPIClient.h
loadTweetWithID:completion:Loads a single Tweet from the network or cache. - (void)loadTweetWithID:(NSString *)tweetIDString completion:(TWTRLoadTweetCompletion)completion ParameterstweetIDString The ID of the desired Tweet. completion Completion bock to be called on response. Called on main queue. Declared In
|
Loads a series of Tweets in a batch. The completion block will be passed an array of zero or more Tweets that loaded successfully. If some Tweets fail to load the array will contain less Tweets than number of requested IDs. If any Tweets fail to load, the IDs of the Tweets that did not load will be provided in the userInfo dictionary property of the error parameter under TWTRTweetsNotLoadedKey
.
- (void)loadTweetsWithIDs:(NSArray *)tweetIDStrings completion:(TWTRLoadTweetsCompletion)completion
tweetIDStrings
An array of Tweet IDs.
completion
Completion block to be called on response. Called on main queue.
TWTRAPIClient.h
loadTweetsWithIDs:completion:Loads a series of Tweets in a batch. The completion block will be passed an array of zero or more Tweets that loaded successfully. If some Tweets fail to load the array will contain less Tweets than number of requested IDs. If any Tweets fail to load, the IDs of the Tweets that did not load will be provided in the userInfo dictionary property of the error parameter under - (void)loadTweetsWithIDs:(NSArray *)tweetIDStrings completion:(TWTRLoadTweetsCompletion)completion ParameterstweetIDStrings An array of Tweet IDs. completion Completion block to be called on response. Called on main queue. Declared In
|
Loads a Twitter User.
- (void)loadUserWithID:(NSString *)userIDString completion:(TWTRLoadUserCompletion)completion
userIDString
The Twitter user ID of the desired user.
completion
Completion block to be called on response. Called on main queue.
TWTRAPIClient.h
loadUserWithID:completion:Loads a Twitter User. - (void)loadUserWithID:(NSString *)userIDString completion:(TWTRLoadUserCompletion)completion ParametersuserIDString The Twitter user ID of the desired user. completion Completion block to be called on response. Called on main queue. Declared In
|
Sends a Twitter request.
- (void)sendTwitterRequest:(NSURLRequest *)request completion:(TWTRNetworkCompletion)completion
request
The Twitter user ID of the desired user.
completion
Completion block to be called on response. Called on main queue.
TWTRAPIClient.h
sendTwitterRequest:completion:Sends a Twitter request. - (void)sendTwitterRequest:(NSURLRequest *)request completion:(TWTRNetworkCompletion)completion Parametersrequest The Twitter user ID of the desired user. completion Completion block to be called on response. Called on main queue. Declared In
|