Permalink
Browse files

Removed -getFollowedTimelineFor:* methods since they are no longer su…

…pported by Twitter.

Removed the methods that used a NSDate for the "since" parameter: they are no longer supported by Twitter.
Added a withMaximumID: method signature to the APIs that support the new "max_id" parameter.
Updated search API to use include additional parameters.
Updated search API to use the current terminology for trends.
Fixed YAJL parsing "created_at" so that it handles the different date formats for the Search and REST APIs.
Improved YAJL parsing when Twitter returns short (and invalid) JSON results.
Simplified the -description method for MGTwitterHTTPURLConnection.
Made many of the delegate methods optional—only -requestSucceeded and requestFailed:withError: are required.
Fixed -_sendRequestWithMethod:path:queryParameters:body:requestType:responseType so it can handle requests for trends.
Added #if DEBUG around NSLog() so a preprocessor definition can be used to control logging.
Fixed a crash in the NSURLConnection authentication challenge if the username and/or password was nil.
Major reorganization of source code so similar methods are grouped together (using the same grouping as Twitter's own documentation.)
Added much more granularity to the MGTwitterRequestType enumeration: an application can now determine which method was used to generate a data object.
  • Loading branch information...
1 parent 134c94d commit c8ba147fc718c8161c4875d17e478379ff9ae781 Craig Hockenberry committed May 4, 2009
View
@@ -15,13 +15,13 @@ @implementation AppController
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Put your Twitter username and password here:
- NSString *username = @"";
- NSString *password = @"";
+ NSString *username = nil;
+ NSString *password = nil;
- // Make sure you entered your login details before running this code... ;)
- if ([username isEqualToString:@""] || [password isEqualToString:@""]) {
- NSLog(@"You forgot to specify your username/password in AppController.m!");
- [NSApp terminate:self];
+ // Most API calls require a name and password to be set...
+ if (! username || ! password) {
+ NSLog(@"You forgot to specify your username/password in AppController.m, things might not work!");
+ NSLog(@"And if things are mysteriously working without the username/password, it's because NSURLConnection is using a session cookie from another connection.");
}
// Create a TwitterEngine and set our login details.
@@ -30,10 +30,10 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
// Configure how the delegate methods are called to deliver results. See MGTwitterEngineDelegate.h for more info
//[twitterEngine setDeliveryOptions:MGTwitterEngineDeliveryIndividualResultsOption];
-
- // Get updates from people the authenticated user follows.
- //NSLog(@"getFollowedTimelineFor: connectionIdentifier = %@", [twitterEngine getFollowedTimelineFor:nil since:nil startingAtPage:0]);
-
+
+ // Get the public timeline
+ NSLog(@"getPublicTimelineSinceID: connectionIdentifier = %@", [twitterEngine getPublicTimeline]);
+
// Other types of information available from the API:
#define TESTING_ID 1131604824
@@ -42,9 +42,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
#define TESTING_MESSAGE_ID 52182684
// Status methods:
-
- NSLog(@"getPublicTimelineSinceID: connectionIdentifier = %@", [twitterEngine getPublicTimelineSinceID:0]);
- //NSLog(@"getUserTimelineFor: connectionIdentifier = %@", [twitterEngine getUserTimelineFor:TESTING_SECONDARY_USER sinceID:0 startingAtPage:0 count:20]);
+ //NSLog(@"getUserTimelineFor: connectionIdentifier = %@", [twitterEngine getUserTimelineFor:TESTING_SECONDARY_USER sinceID:0 startingAtPage:0 count:3]);
//NSLog(@"getUpdate: connectionIdentifier = %@", [twitterEngine getUpdate:TESTING_ID]);
//NSLog(@"sendUpdate: connectionIdentifier = %@", [twitterEngine sendUpdate:[@"This is a test on " stringByAppendingString:[[NSDate date] description]]]);
//NSLog(@"getRepliesStartingAtPage: connectionIdentifier = %@", [twitterEngine getRepliesStartingAtPage:0]);
@@ -166,8 +164,10 @@ - (void)imageReceived:(NSImage *)image forRequest:(NSString *)connectionIdentifi
[[image TIFFRepresentation] writeToFile:path atomically:NO];
}
-- (void)connectionFinished
+- (void)connectionFinished:(NSString *)connectionIdentifier
{
+ NSLog(@"Connection finished %@", connectionIdentifier);
+
if ([twitterEngine numberOfConnections] == 0)
{
[NSApp terminate:self];
View
@@ -79,65 +79,63 @@
// ======================================================================================================
// Twitter REST API methods
-// See documentation at: http://apiwiki.twitter.com/REST+API+Documentation
+// See documentation at: http://apiwiki.twitter.com/Twitter-API-Documentation
// All methods below return a unique connection identifier.
// ======================================================================================================
-// Status methods - http://apiwiki.twitter.com/REST+API+Documentation#StatusMethods
+// Status methods
-- (NSString *)getPublicTimelineSinceID:(int)updateID; // statuses/public_timeline
+- (NSString *)getPublicTimeline; // statuses/public_timeline
-- (NSString *)getFollowedTimelineFor:(NSString *)username since:(NSDate *)date startingAtPage:(int)pageNum; // statuses/friends_timeline
-- (NSString *)getFollowedTimelineFor:(NSString *)username since:(NSDate *)date startingAtPage:(int)pageNum count:(int)count; // statuses/friends_timeline
-- (NSString *)getFollowedTimelineFor:(NSString *)username sinceID:(int)updateID startingAtPage:(int)pageNum count:(int)count; // statuses/friends_timeline
+- (NSString *)getFollowedTimelineSinceID:(int)sinceID startingAtPage:(int)pageNum count:(int)count; // statuses/friends_timeline
+- (NSString *)getFollowedTimelineSinceID:(int)sinceID withMaximumID:(int)maxID startingAtPage:(int)pageNum count:(int)count; // statuses/friends_timeline
-- (NSString *)getUserTimelineFor:(NSString *)username since:(NSDate *)date count:(int)numUpdates; // statuses/user_timeline
-- (NSString *)getUserTimelineFor:(NSString *)username since:(NSDate *)date startingAtPage:(int)pageNum count:(int)numUpdates; // statuses/user_timeline
-- (NSString *)getUserTimelineFor:(NSString *)username sinceID:(int)updateID startingAtPage:(int)pageNum count:(int)numUpdates; // statuses/user_timeline
+- (NSString *)getUserTimelineFor:(NSString *)username sinceID:(int)sinceID startingAtPage:(int)pageNum count:(int)count; // statuses/user_timeline & statuses/user_timeline/user
+- (NSString *)getUserTimelineFor:(NSString *)username sinceID:(int)sinceID withMaximumID:(int)maxID startingAtPage:(int)pageNum count:(int)count; // statuses/user_timeline & statuses/user_timeline/user
- (NSString *)getUpdate:(int)updateID; // statuses/show
- (NSString *)sendUpdate:(NSString *)status; // statuses/update
- (NSString *)sendUpdate:(NSString *)status inReplyTo:(int)updateID; // statuses/update
-- (NSString *)getRepliesStartingAtPage:(int)pageNum; // statuses/replies
-- (NSString *)getRepliesSince:(NSDate *)date startingAtPage:(int)pageNum count:(int)count; // statuses/replies
-- (NSString *)getRepliesSinceID:(int)updateID startingAtPage:(int)pageNum count:(int)count; // statuses/replies
+- (NSString *)getRepliesStartingAtPage:(int)pageNum; // statuses/mentions
+- (NSString *)getRepliesSinceID:(int)sinceID startingAtPage:(int)pageNum count:(int)count; // statuses/mentions
+- (NSString *)getRepliesSinceID:(int)sinceID withMaximumID:(int)maxID startingAtPage:(int)pageNum count:(int)count; // statuses/mentions
- (NSString *)deleteUpdate:(int)updateID; // statuses/destroy
- (NSString *)getFeaturedUsers; // statuses/features (undocumented, returns invalid JSON data)
-// User methods - http://apiwiki.twitter.com/REST+API+Documentation#UserMethods
+// User methods
-- (NSString *)getRecentlyUpdatedFriendsFor:(NSString *)username startingAtPage:(int)pageNum; // statuses/friends
+- (NSString *)getRecentlyUpdatedFriendsFor:(NSString *)username startingAtPage:(int)pageNum; // statuses/friends & statuses/friends/user
- (NSString *)getFollowersIncludingCurrentStatus:(BOOL)flag; // statuses/followers
- (NSString *)getUserInformationFor:(NSString *)usernameOrID; // users/show
- (NSString *)getUserInformationForEmail:(NSString *)email; // users/show
-// Direct Message methods - http://apiwiki.twitter.com/REST+API+Documentation#DirectMessageMethods
+// Direct Message methods
-- (NSString *)getDirectMessagesSince:(NSDate *)date startingAtPage:(int)pageNum; // direct_messages
-- (NSString *)getDirectMessagesSinceID:(int)updateID startingAtPage:(int)pageNum; // direct_messages
+- (NSString *)getDirectMessagesSinceID:(int)sinceID startingAtPage:(int)pageNum; // direct_messages
+- (NSString *)getDirectMessagesSinceID:(int)sinceID withMaximumID:(int)maxID startingAtPage:(int)pageNum count:(int)count; // direct_messages
-- (NSString *)getSentDirectMessagesSince:(NSDate *)date startingAtPage:(int)pageNum; // direct_messages/sent
-- (NSString *)getSentDirectMessagesSinceID:(int)updateID startingAtPage:(int)pageNum; // direct_messages/sent
+- (NSString *)getSentDirectMessagesSinceID:(int)sinceID startingAtPage:(int)pageNum; // direct_messages/sent
+- (NSString *)getSentDirectMessagesSinceID:(int)sinceID withMaximumID:(int)maxID startingAtPage:(int)pageNum count:(int)count; // direct_messages/sent
- (NSString *)sendDirectMessage:(NSString *)message to:(NSString *)username; // direct_messages/new
- (NSString *)deleteDirectMessage:(int)updateID;// direct_messages/destroy
-// Friendship methods - http://apiwiki.twitter.com/REST+API+Documentation#FriendshipMethods
+// Friendship methods
- (NSString *)enableUpdatesFor:(NSString *)username; // friendships/create (follow username)
- (NSString *)disableUpdatesFor:(NSString *)username; // friendships/destroy (unfollow username)
- (NSString *)isUser:(NSString *)username1 receivingUpdatesFor:(NSString *)username2; // friendships/exists (test if username1 follows username2)
-// Account methods - http://apiwiki.twitter.com/REST+API+Documentation#AccountMethods
+// Account methods
- (NSString *)checkUserCredentials; // account/verify_credentials
- (NSString *)endUserSession; // account/end_session
@@ -157,26 +155,26 @@
// - (NSString *)getUserUpdatesArchiveStartingAtPage:(int)pageNum; // account/archive (removed, use /statuses/user_timeline instead)
-// Favorite methods - http://apiwiki.twitter.com/REST+API+Documentation#FavoriteMethods
+// Favorite methods
- (NSString *)getFavoriteUpdatesFor:(NSString *)username startingAtPage:(int)pageNum; // favorites
- (NSString *)markUpdate:(int)updateID asFavorite:(BOOL)flag; // favorites/create, favorites/destroy
-// Notification methods - http://apiwiki.twitter.com/REST+API+Documentation#NotificationMethods
+// Notification methods
- (NSString *)enableNotificationsFor:(NSString *)username; // notifications/follow
- (NSString *)disableNotificationsFor:(NSString *)username; // notifications/leave
-// Block methods - http://apiwiki.twitter.com/REST+API+Documentation#BlockMethods
+// Block methods
- (NSString *)block:(NSString *)username; // blocks/create
- (NSString *)unblock:(NSString *)username; // blocks/destroy
-// Help methods - http://apiwiki.twitter.com/REST+API+Documentation#HelpMethods
+// Help methods
- (NSString *)testService; // help/test
@@ -187,19 +185,21 @@
// ======================================================================================================
// Twitter Search API methods
-// See documentation at: http://apiwiki.twitter.com/Search+API+Documentation
+// See documentation at: http://apiwiki.twitter.com/Twitter-API-Documentation
// All methods below return a unique connection identifier.
// ======================================================================================================
#if YAJL_AVAILABLE
-// Search method - http://apiwiki.twitter.com/Search+API+Documentation#Search
+// Search method
-- (NSString *)getSearchResultsForQuery:(NSString *)query sinceID:(int)updateID startingAtPage:(int)pageNum count:(int)count; // search
+- (NSString *)getSearchResultsForQuery:(NSString *)query;
+- (NSString *)getSearchResultsForQuery:(NSString *)query sinceID:(int)sinceID startingAtPage:(int)pageNum count:(int)count; // search
+- (NSString *)getSearchResultsForQuery:(NSString *)query sinceID:(int)sinceID startingAtPage:(int)pageNum count:(int)count geocode:(NSString *)geocode;
-// Trends method - http://apiwiki.twitter.com/Search+API+Documentation#Trends
+// Trends method
-- (NSString *)getTrends; // trends
+- (NSString *)getCurrentTrends; // current trends
#endif
Oops, something went wrong.

0 comments on commit c8ba147

Please sign in to comment.