Skip to content

Commit

Permalink
Fixed TouchJson bug with sendRetweet/deleteUpdate & XAuth
Browse files Browse the repository at this point in the history
  • Loading branch information
farnell committed May 8, 2010
1 parent 742ab9c commit 7b572ca
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 18 deletions.
48 changes: 31 additions & 17 deletions MGTwitterEngine.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@
#define MAX_LOCATION_LENGTH 30
#define MAX_DESCRIPTION_LENGTH 160

#define DEFAULT_CLIENT_NAME @"MGTwitterEngine"
#define DEFAULT_CLIENT_NAME @"MeMap"
#define DEFAULT_CLIENT_VERSION @"1.0"
#define DEFAULT_CLIENT_URL @"http://mattgemmell.com/source"
#define DEFAULT_CLIENT_TOKEN @"mgtwitterengine"
#define DEFAULT_CLIENT_URL @"http://www.memap.com"
#define DEFAULT_CLIENT_TOKEN @"memap"

#define URL_REQUEST_TIMEOUT 25.0 // Twitter usually fails quickly if it's going to fail at all.

Expand Down Expand Up @@ -456,24 +456,23 @@ - (NSString *)_sendRequestWithMethod:(NSString *)method
NSString *finalBody = @"";
if (body) {
finalBody = [finalBody stringByAppendingString:body];
}
if (_clientSourceToken) {
finalBody = [finalBody stringByAppendingString:[NSString stringWithFormat:@"%@source=%@",
(body) ? @"&" : @"?" ,
_clientSourceToken]];
}

if (finalBody) {
[theRequest setHTTPBody:[finalBody dataUsingEncoding:NSUTF8StringEncoding]];
#if DEBUG
if (YES) {
NSLog(@"MGTwitterEngine: finalBody = %@", finalBody);
if (_clientSourceToken) {
finalBody = [finalBody stringByAppendingString:[NSString stringWithFormat:@"%@source=%@",
(body) ? @"&" : @"?" ,
_clientSourceToken]];
}
if (finalBody) {
[theRequest setHTTPBody:[finalBody dataUsingEncoding:NSUTF8StringEncoding]];
#if DEBUG
if (YES) {
NSLog(@"MGTwitterEngine: finalBody = %@", finalBody);
}
#endif
}
}
}

}


// Create a connection using this request, with the default timeout and caching policy,
// and appropriate Twitter request and response types for parsing and error reporting.
MGTwitterHTTPURLConnection *connection;
Expand Down Expand Up @@ -716,9 +715,24 @@ - (void)_parseDataForConnection:(MGTwitterHTTPURLConnection *)connection
break;
}
#elif TOUCHJSON_AVAILABLE
/*
[MGTwitterTouchJSONParser parserWithJSON:jsonData delegate:self
connectionIdentifier:identifier requestType:requestType
responseType:responseType URL:URL deliveryOptions:_deliveryOptions];
*/
switch (responseType) {
case MGTwitterOAuthToken:;
OAToken *token = [[[OAToken alloc] initWithHTTPResponseBody:[[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding] autorelease]] autorelease];
[self parsingSucceededForRequest:identifier ofResponseType:requestType
withParsedObjects:[NSArray arrayWithObject:token]];
break;
default:
[MGTwitterTouchJSONParser parserWithJSON:jsonData delegate:self
connectionIdentifier:identifier requestType:requestType
responseType:responseType URL:URL deliveryOptions:_deliveryOptions];
break;
}

#endif

}
Expand Down
2 changes: 1 addition & 1 deletion MGTwitterEngineGlobalHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
*/

#define YAJL_AVAILABLE 0
#define TOUCHJSON_AVAILABLE 0
#define TOUCHJSON_AVAILABLE 1

#if YAJL_AVAILABLE
/*
Expand Down

0 comments on commit 7b572ca

Please sign in to comment.