Skip to content
Browse files

Fixed error where I used ints and not "long long" values for the curs…

…or's. Note I have not used MGTwitterEngineID as the cursors need to be signed, not unsigned.

I have also added some error checking in the getFollowerIDs & getFriendIDs; a cursor of 0 is invalid, as is a username name of "".

I have also changed the format of the request to match the other API request methods
  • Loading branch information...
1 parent db9a825 commit 57edfe7e9907a864909aee8c0553636037fd614c @tarasis tarasis committed Mar 21, 2010
Showing with 22 additions and 23 deletions.
  1. +2 −7 AppController.m
  2. +2 −2 MGTwitterEngine.h
  3. +18 −14 MGTwitterEngine.m
View
9 AppController.m
@@ -93,8 +93,8 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
//NSLog(@"testService: connectionIdentifier = %@", [twitterEngine testService]);
// Social Graph methods
- //NSLog(@"getFriendIDsFor: connectionIdentifier = %@", [twitterEngine getFriendIDsFor:@"duemoko" startingFromCursor:-1]);
- //NSLog(@"getFollowerIDsFor: connectionIdentifier = %@", [twitterEngine getFollowerIDsFor:username startingFromCursor:-1]);
+ //NSLog(@"getFriendIDsFor: connectionIdentifier = %@", [twitterEngine getFriendIDsFor:TESTING_SECONDARY_USER startingFromCursor:-1]);
+ //NSLog(@"getFollowerIDsFor: connectionIdentifier = %@", [twitterEngine getFollowerIDsFor:TESTING_SECONDARY_USER startingFromCursor:-1]);
#if YAJL_AVAILABLE
// Search method
@@ -163,11 +163,6 @@ - (void)searchResultsReceived:(NSArray *)searchResults forRequest:(NSString *)co
- (void)socialGraphInfoReceived:(NSArray *)socialGraphInfo forRequest:(NSString *)connectionIdentifier
{
NSLog(@"Got social graph results for %@:\r%@", connectionIdentifier, socialGraphInfo);
-
-// NSLog(@"IDs: %@", [socialGraphInfo valueForKey:@"ids"]);
-// NSLog(@"previous_cursor: %@", [socialGraphInfo valueForKey:@"previous_cursor"]);
-// NSLog(@"next_cursor: %@", [socialGraphInfo valueForKey:@"next_cursor"]);
-// NSLog(@"source_api_request_type: %@", [socialGraphInfo valueForKey:@"source_api_request_type"]);
}
View
4 MGTwitterEngine.h
@@ -184,8 +184,8 @@
// Social Graph methods
-- (NSString *)getFriendIDsFor:(NSString *)username startingFromCursor:(int)cursor; // friends/ids
-- (NSString *)getFollowerIDsFor:(NSString *)username startingFromCursor:(int)cursor; // followers/ids
+- (NSString *)getFriendIDsFor:(NSString *)username startingFromCursor:(long long)cursor; // friends/ids
+- (NSString *)getFollowerIDsFor:(NSString *)username startingFromCursor:(long long)cursor; // followers/ids
#pragma mark Search API methods
View
32 MGTwitterEngine.m
@@ -1578,37 +1578,41 @@ - (NSString *)getDowntimeSchedule
#pragma mark Social Graph methods
-- (NSString *)getFriendIDsFor:(NSString *)username startingFromCursor:(int)cursor
+- (NSString *)getFriendIDsFor:(NSString *)username startingFromCursor:(long long)cursor
{
- //NSLog(@"getFriendIDsFor:%@ atCursor:%d", username, cursor);
+ //NSLog(@"getFriendIDsFor:%@ atCursor:%lld", username, cursor);
+ if (cursor == 0 || [username isEqualToString:@""])
+ return nil;
+
NSString *path = [NSString stringWithFormat:@"friends/ids.%@", API_FORMAT];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithCapacity:0];
- if (username != nil) {
- [params setObject:username forKey:@"screen_name"];
+ if (username) {
+ path = [NSString stringWithFormat:@"friends/ids/%@.%@", username, API_FORMAT];
}
- if (cursor >= -1) {
- [params setObject:[NSString stringWithFormat:@"%ld", cursor] forKey:@"cursor"];
- }
+
+ [params setObject:[NSString stringWithFormat:@"%lld", cursor] forKey:@"cursor"];
return [self _sendRequestWithMethod:nil path:path queryParameters:params body:nil
requestType:MGTwitterFriendIDsRequest
responseType:MGTwitterSocialGraph];
}
-- (NSString *)getFollowerIDsFor:(NSString *)username startingFromCursor:(int)cursor
+- (NSString *)getFollowerIDsFor:(NSString *)username startingFromCursor:(long long)cursor
{
- //NSLog(@"getFollowerIDsFor:%@ atCursor:%d", username, cursor);
+ //NSLog(@"getFollowerIDsFor:%@ atCursor:%lld", username, cursor);
+ if (cursor == 0 || [username isEqualToString:@""])
+ return nil;
+
NSString *path = [NSString stringWithFormat:@"followers/ids.%@", API_FORMAT];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithCapacity:0];
- if (username != nil) {
- [params setObject:username forKey:@"screen_name"];
+ if (username) {
+ path = [NSString stringWithFormat:@"followers/ids/%@.%@", username, API_FORMAT];
}
- if (cursor >= -1) {
- [params setObject:[NSString stringWithFormat:@"%ld", cursor] forKey:@"cursor"];
- }
+
+ [params setObject:[NSString stringWithFormat:@"%lld", cursor] forKey:@"cursor"];
return [self _sendRequestWithMethod:nil path:path queryParameters:params body:nil
requestType:MGTwitterFollowerIDsRequest

0 comments on commit 57edfe7

Please sign in to comment.
Something went wrong with that request. Please try again.