Skip to content

Commit

Permalink
Added first of user/lists API methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
catsby authored and alexrepty committed Sep 4, 2010
1 parent 34f0344 commit be2b3e9
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions AppController.m
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ - (void)socialGraphInfoReceived:(NSArray *)socialGraphInfo forRequest:(NSString
NSLog(@"Got social graph results for %@:\r%@", connectionIdentifier, socialGraphInfo);
}

- (void)userListsReceived:(NSArray *)userInfo forRequest:(NSString *)connectionIdentifier
{
NSLog(@"Got user lists for %@:\r%@", connectionIdentifier, userInfo);
}

- (void)imageReceived:(NSImage *)image forRequest:(NSString *)connectionIdentifier
{
Expand Down
2 changes: 2 additions & 0 deletions MGTwitterEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@

- (NSString *)getUserInformationForEmail:(NSString *)email; // users/show

// List Methods
- (NSString *)getListsForUser:(NSString *)username;

// Direct Message methods

Expand Down
23 changes: 23 additions & 0 deletions MGTwitterEngine.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#import "MGTwitterMessagesParser.h"
#import "MGTwitterMiscParser.h"
#import "MGTwitterSocialGraphParser.h"
#import "MGTwitterUserListsParser.h"
#endif
#endif

Expand Down Expand Up @@ -851,6 +852,13 @@ - (void)_parseDataForConnection:(MGTwitterHTTPURLConnection *)connection
connectionIdentifier:identifier requestType:requestType
responseType:responseType];
break;
case MGTwitterUserLists:
NSLog(@"response type: %d", responseType);
[MGTwitterUserListsParser parserWithXML:xmlData delegate:self
connectionIdentifier:identifier requestType:requestType
responseType:responseType];
break;

case MGTwitterSocialGraph:
[MGTwitterSocialGraphParser parserWithXML:xmlData delegate:self
connectionIdentifier:identifier requestType:requestType
Expand Down Expand Up @@ -880,6 +888,7 @@ - (void)parsingSucceededForRequest:(NSString *)identifier
withParsedObjects:(NSArray *)parsedObjects
{
// Forward appropriate message to _delegate, depending on responseType.
NSLog(@"here at parsingSucceededForRequest");
switch (responseType) {
case MGTwitterStatuses:
case MGTwitterStatus:
Expand Down Expand Up @@ -910,6 +919,10 @@ - (void)parsingSucceededForRequest:(NSString *)identifier
if ([self _isValidDelegateForSelector:@selector(socialGraphInfoReceived:forRequest:)])
[_delegate socialGraphInfoReceived: parsedObjects forRequest:identifier];
break;
case MGTwitterUserLists:
if ([self _isValidDelegateForSelector:@selector(userListsReceived:forRequest:)])
[_delegate userListsReceived: parsedObjects forRequest:identifier];
break;
case MGTwitterOAuthTokenRequest:
if ([self _isValidDelegateForSelector:@selector(accessTokenReceived:forRequest:)] && [parsedObjects count] > 0)
[_delegate accessTokenReceived:[parsedObjects objectAtIndex:0]
Expand Down Expand Up @@ -1522,6 +1535,16 @@ - (NSString *)deleteDirectMessage:(MGTwitterEngineID)updateID
responseType:MGTwitterDirectMessage];
}

#pragma mark Lists

- (NSString *)getListsForUser:(NSString *)username
{
NSString *path = [NSString stringWithFormat:@"%@/lists.%@", username, API_FORMAT];

return [self _sendRequestWithMethod:nil path:path queryParameters:nil body:nil
requestType:MGTwitterUserListsRequest
responseType:MGTwitterUserLists];
}

#pragma mark Friendship methods

Expand Down
6 changes: 6 additions & 0 deletions MGTwitterEngine.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
C9FEB12C0D6095AF009AA322 /* MGTwitterStatusesParser.m in Sources */ = {isa = PBXBuildFile; fileRef = C9FEB12B0D6095AF009AA322 /* MGTwitterStatusesParser.m */; };
D47CF9B511541D0A00E07931 /* MGTwitterSocialGraphParser.m in Sources */ = {isa = PBXBuildFile; fileRef = D47CF9B411541D0A00E07931 /* MGTwitterSocialGraphParser.m */; };
D47CFCA9115567ED00E07931 /* MGTwitterSocialGraphLibXMLParser.m in Sources */ = {isa = PBXBuildFile; fileRef = D47CFCA8115567ED00E07931 /* MGTwitterSocialGraphLibXMLParser.m */; };
F4763D2A11C1837300A35E7E /* MGTwitterUserListsParser.m in Sources */ = {isa = PBXBuildFile; fileRef = F4763D2911C1837300A35E7E /* MGTwitterUserListsParser.m */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -212,6 +213,8 @@
D47CF9B411541D0A00E07931 /* MGTwitterSocialGraphParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGTwitterSocialGraphParser.m; sourceTree = "<group>"; };
D47CFCA7115567ED00E07931 /* MGTwitterSocialGraphLibXMLParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGTwitterSocialGraphLibXMLParser.h; sourceTree = "<group>"; };
D47CFCA8115567ED00E07931 /* MGTwitterSocialGraphLibXMLParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGTwitterSocialGraphLibXMLParser.m; sourceTree = "<group>"; };
F4763D2811C1837300A35E7E /* MGTwitterUserListsParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGTwitterUserListsParser.h; sourceTree = "<group>"; };
F4763D2911C1837300A35E7E /* MGTwitterUserListsParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGTwitterUserListsParser.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -504,6 +507,8 @@
C90F74CB0D6A3B5300F602A5 /* Twitter NSXML Parsers */ = {
isa = PBXGroup;
children = (
F4763D2811C1837300A35E7E /* MGTwitterUserListsParser.h */,
F4763D2911C1837300A35E7E /* MGTwitterUserListsParser.m */,
C90F74CC0D6A3B7500F602A5 /* MGTwitterXMLParser.h */,
C90F74CD0D6A3B7500F602A5 /* MGTwitterXMLParser.m */,
C9FEB12A0D6095AF009AA322 /* MGTwitterStatusesParser.h */,
Expand Down Expand Up @@ -663,6 +668,7 @@
1E798A6D118D077E00DDD6D9 /* CJSONScanner.m in Sources */,
1E798A6E118D077E00DDD6D9 /* CJSONSerializer.m in Sources */,
1E798A6F118D077E00DDD6D9 /* CSerializedJSONData.m in Sources */,
F4763D2A11C1837300A35E7E /* MGTwitterUserListsParser.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
1 change: 1 addition & 0 deletions MGTwitterEngineDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ typedef enum _MGTwitterEngineDeliveryOptions {
- (void)statusesReceived:(NSArray *)statuses forRequest:(NSString *)connectionIdentifier;
- (void)directMessagesReceived:(NSArray *)messages forRequest:(NSString *)connectionIdentifier;
- (void)userInfoReceived:(NSArray *)userInfo forRequest:(NSString *)connectionIdentifier;
- (void)userListsReceived:(NSArray *)userInfo forRequest:(NSString *)connectionIdentifier;
- (void)miscInfoReceived:(NSArray *)miscInfo forRequest:(NSString *)connectionIdentifier;
#if YAJL_AVAILABLE || TOUCHJSON_AVAILABLE
- (void)searchResultsReceived:(NSArray *)searchResults forRequest:(NSString *)connectionIdentifier;
Expand Down

0 comments on commit be2b3e9

Please sign in to comment.