Skip to content

Commit

Permalink
added support for extended tweets https://dev.twitter.com/overview/ap…
Browse files Browse the repository at this point in the history
  • Loading branch information
nst committed Sep 25, 2016
1 parent cb2beca commit c544385
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 9 deletions.
5 changes: 4 additions & 1 deletion STTwitter/NSError+STTwitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ static NSString *kSTTwitterRateLimitResetDate = @"STTwitterRateLimitResetDate";
typedef NS_ENUM( NSInteger, STTwitterTwitterErrorCode ) {
STTwitterTwitterErrorCouldNotAuthenticate = 32, // Your call could not be completed as dialed.
STTwitterTwitterErrorPageDoesNotExist = 34, // Corresponds with an HTTP 404 - the specified resource was not found.
STTwitterTwitterErrorInvalidAttachmentURL = 44, // Corresponds with HTTP 400. The URL value provided is not a URL that can be attached to this Tweet.
STTwitterTwitterErrorAccountSuspended = 64, // Corresponds with an HTTP 403 — the access token being used belongs to a suspended user and they can't complete the action you're trying to take
STTwitterTwitterErrorAPIv1Inactive = 68, // Corresponds to a HTTP request to a retired v1-era URL.
STTwitterTwitterErrorRateLimitExceeded = 88, // The request limit for this resource has been reached for the current rate limit window.
Expand All @@ -32,7 +33,9 @@ typedef NS_ENUM( NSInteger, STTwitterTwitterErrorCode ) {
STTwitterTwitterErrorBadAuthenticationData = 215, // Typically sent with 1.1 responses with HTTP code 400. The method requires authentication but it was not presented or was wholly invalid.
STTwitterTwitterErrorUserMustVerifyLogin = 231, // Returned as a challenge in xAuth when the user has login verification enabled on their account and needs to be directed to twitter.com to generate a temporary password.
STTwitterTwitterErrorRetiredEndpoint = 251, // Corresponds to a HTTP request to a retired URL.
STTwitterTwitterErrorApplicationCannotWrite = 261 // Corresponds with HTTP 403 — thrown when the application is restricted from POST, PUT, or DELETE actions. See How to appeal application suspension and other disciplinary actions.
STTwitterTwitterErrorApplicationCannotWrite = 261, // Corresponds with HTTP 403 — thrown when the application is restricted from POST, PUT, or DELETE actions. See How to appeal application suspension and other disciplinary actions.
STTwitterTwitterErrorCannotReplyToDeletedOrInvisibleTweet = 385, // Corresponds with HTTP 403. A reply can only be sent with reference to an existing public Tweet.
STTwitterTwitterErrorTooManyAttachmentTypes = 386 // Corresponds with HTTP 403. A Tweet is limited to a single attachment resource (media, Quote Tweet, etc.)
};

@interface NSError (STTwitter)
Expand Down
19 changes: 19 additions & 0 deletions STTwitter/STTwitterAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ authenticateInsteadOfAuthorize:(BOOL)authenticateInsteadOfAuthorize // use NO if
- (NSObject<STTwitterRequestProtocol> *)getStatusesRetweetsForID:(NSString *)statusID
count:(NSString *)count
trimUser:(NSNumber *)trimUser
useExtentedTweetMode:(NSNumber *)useExtendedTweetMode
successBlock:(void(^)(NSArray *statuses))successBlock
errorBlock:(void(^)(NSError *error))errorBlock;

Expand Down Expand Up @@ -353,6 +354,7 @@ authenticateInsteadOfAuthorize:(BOOL)authenticateInsteadOfAuthorize // use NO if
trimUser:(NSNumber *)trimUser
includeMyRetweet:(NSNumber *)includeMyRetweet
includeEntities:(NSNumber *)includeEntities
useExtentedTweetMode:(NSNumber *)useExtendedTweetMode
successBlock:(void(^)(NSDictionary *status))successBlock
errorBlock:(void(^)(NSError *error))errorBlock;

Expand All @@ -364,6 +366,7 @@ authenticateInsteadOfAuthorize:(BOOL)authenticateInsteadOfAuthorize // use NO if

- (NSObject<STTwitterRequestProtocol> *)postStatusesDestroy:(NSString *)statusID
trimUser:(NSNumber *)trimUser
useExtentedTweetMode:(NSNumber *)useExtendedTweetMode
successBlock:(void(^)(NSDictionary *status))successBlock
errorBlock:(void(^)(NSError *error))errorBlock;

Expand Down Expand Up @@ -392,12 +395,20 @@ authenticateInsteadOfAuthorize:(BOOL)authenticateInsteadOfAuthorize // use NO if
placeID:(NSString *)placeID
displayCoordinates:(NSNumber *)displayCoordinates
trimUser:(NSNumber *)trimUser
autoPopulateReplyMetadata:(NSNumber *)autoPopulateReplyMetadata
excludeReplyUserIDsStrings:(NSArray *)excludeReplyUserIDsString
attachmentURLString:(NSString *)attachmentURLString // URLs passed to the attachment_url parameter not matching either a Tweet permalink or DM deep link will fail at Tweet creation and cause an exception.
useExtentedTweetMode:(NSNumber *)useExtendedTweetMode
successBlock:(void(^)(NSDictionary *status))successBlock
errorBlock:(void(^)(NSError *error))errorBlock;

// starting May 28th, 2014
// https://dev.twitter.com/notifications/multiple-media-entities-in-tweets
// https://dev.twitter.com/docs/api/multiple-media-extended-entities

// September 2016: extented Tweets support with new parameters auto_populate_reply_metadata, exclude_reply_user_ids and attachment_url
// https://dev.twitter.com/overview/api/upcoming-changes-to-tweets

- (NSObject<STTwitterRequestProtocol> *)postStatusesUpdate:(NSString *)status
inReplyToStatusID:(NSString *)existingStatusID
mediaIDs:(NSArray *)mediaIDs
Expand All @@ -406,6 +417,10 @@ authenticateInsteadOfAuthorize:(BOOL)authenticateInsteadOfAuthorize // use NO if
placeID:(NSString *)placeID
displayCoordinates:(NSNumber *)displayCoordinates
trimUser:(NSNumber *)trimUser
autoPopulateReplyMetadata:(NSNumber *)autoPopulateReplyMetadata
excludeReplyUserIDsStrings:(NSArray *)excludeReplyUserIDsString
attachmentURLString:(NSString *)attachmentURLString // URLs passed to the attachment_url parameter not matching either a Tweet permalink or DM deep link will fail at Tweet creation and cause an exception.
useExtentedTweetMode:(NSNumber *)useExtendedTweetMode
successBlock:(void(^)(NSDictionary *status))successBlock
errorBlock:(void(^)(NSError *error))errorBlock;

Expand All @@ -423,11 +438,13 @@ authenticateInsteadOfAuthorize:(BOOL)authenticateInsteadOfAuthorize // use NO if

- (NSObject<STTwitterRequestProtocol> *)postStatusRetweetWithID:(NSString *)statusID
trimUser:(NSNumber *)trimUser
useExtentedTweetMode:(NSNumber *)useExtendedTweetMode
successBlock:(void(^)(NSDictionary *status))successBlock
errorBlock:(void(^)(NSError *error))errorBlock;

// convenience
- (NSObject<STTwitterRequestProtocol> *)postStatusRetweetWithID:(NSString *)statusID
useExtentedTweetMode:(NSNumber *)useExtendedTweetMode
successBlock:(void(^)(NSDictionary *status))successBlock
errorBlock:(void(^)(NSError *error))errorBlock;

Expand All @@ -446,6 +463,7 @@ authenticateInsteadOfAuthorize:(BOOL)authenticateInsteadOfAuthorize // use NO if

- (NSObject<STTwitterRequestProtocol> *)postStatusUnretweetWithID:(NSString *)statusID
trimUser:(NSNumber *)trimUser
useExtentedTweetMode:(NSNumber *)useExtendedTweetMode
successBlock:(void(^)(NSDictionary *status))successBlock
errorBlock:(void(^)(NSError *error))errorBlock;

Expand Down Expand Up @@ -499,6 +517,7 @@ authenticateInsteadOfAuthorize:(BOOL)authenticateInsteadOfAuthorize // use NO if
align:(NSString *)align // 'left', 'right', 'center' or 'none' (default)
related:(NSString *)related // eg. twitterapi,twittermedia,twitter
lang:(NSString *)lang
useExtentedTweetMode:(NSNumber *)useExtendedTweetMode
successBlock:(void(^)(NSDictionary *status))successBlock
errorBlock:(void(^)(NSError *error))errorBlock;

Expand Down
Loading

0 comments on commit c544385

Please sign in to comment.