It may be deliberate that this function doesn't work but that doesn't make much sense. I'm trying to use SA_OAuthTwitterEngine as the sole Twitter engine in my app but I'm having problems with the getSearchResultsForQuery: method (yes, I've hooked up the YAJL library). Every single time I send a request using the getSearchResultsForQuery: selector on my SA_OAuthTwitterEngine I'm get the following error:
"The operation couldn’t be completed. (HTTP error 400.)"
MGTwitterEngine produces no such error. You wouldn't think calling this selector would be a problem since it inherits directly from MGTwitterClient and therefore provides the interface, but actually it is. The problem lies in SA_OAuthTwitterEngine's implementation of
- - (NSString *)_sendRequestWithMethod:(NSString *)method
- path:(NSString *)path
- queryParameters:(NSDictionary *)params
- body:(NSString *)body
- requestType:(MGTwitterRequestType)requestType
- responseType:(MGTwitterResponseType)responseType;
which overrides the default in the base MGTwitterEngine. It's described quite nicely in a comment but does nothing to explain the consequences of doing it this way.
- // -------------------------------------------------------------------------------
- // mdificatfrom the base clase
- // the base class appends parameters here
- // -------------------------------------------------------------------------------
- // if (params) {
- // fullPath = [self _queryStringWithBase:fullPath parameters:params prefixed:YES];
- // }
- // -------------------------------------------------------------------------------
The problem is that it doesn't consider which type of
MGTwitterRequestType is being used before making the decision to construct an OAuth request. Certain actions simply don't require an OAuth-formatted request, and in this case it just plain doesn't work. MGTwitterSearchRequest and MGTwitterSearchCurrentTrendsRequest are two types that I don't believe require authentication, and therefore have no use for OAuth requests. To fix the problem for this particular request type add the following code to the beginning of SA_OAuthTwitterEngine's implementation of _sendRequestWithMethod:- //Defer work to super because these requests don't support OAuth
- if (requestType == MGTwitterSearchRequest || requestType == MGTwitterSearchCurrentTrendsRequest) {
- return [super _sendRequestWithMethod:method path:path queryParameters<:params body:body requestType:requestType responseType:responseType];
- }
This certainly beats lugging around an instance of each class, one for reading and one for writing. Hopefully this helps someone out, it was driving me nuts.
After using GeSHi I have now decided that I need a new blogger theme....but one thing at a time. Back to XCode.







0 comments:
Post a Comment