rsieiro / RSOAuthEngine

ARC based OAuth engine for MKNetworkKit
http://rodrigo.sharpcube.com
150 stars 33 forks source link

Logging JSON Twitter Example #24

Open prnk28 opened 9 years ago

prnk28 commented 9 years ago

I am trying to log the JSON Response for a Home Timeline w/ your Twitter Example, and MKNetworking but I seem to get no response. Am I doing it right?

 (void)getTimelineWithCompletionBlock:(RSTwitterEngineCompletionBlock)completionBlock
{
    if (!self.isAuthenticated) {
        [self authenticateWithCompletionBlock:^(NSError *error) {
            if (error) {
                // Authentication failed, return the error
                completionBlock(error);
            } else {
                // Authentication succeeded, call this method again
                [self getTimelineWithCompletionBlock:completionBlock];
            }
        }];

        // This method will be called again once the authentication completes
        return;
    }

    MKNetworkOperation *op = [self operationWithPath:TW_TIMELINE
                                              params:nil
                                          httpMethod:@"GET"
                                                 ssl:YES];

    [op addCompletionHandler:^(MKNetworkOperation *completedOperation) {
        completionBlock(nil);
        NSLog(completedOperation.responseJSON);
    } errorHandler:^(MKNetworkOperation *completedOperation, NSError *error) {
        completionBlock(error);
    }];
}
rsieiro commented 9 years ago

Looks fine. I'd put the NSLog line before the completionBlock (although not strictly necessary). Make sure you #define the TW_TIMELINE constant with the correct path (Twitter doesn't allow you to use API v1.0 anymore, it needs to point to API v1.1) and check the console for any auth errors that might be happening.

prnk28 commented 9 years ago

The problem is that nothing is being logged here is what my TW_TIMELINE is "1.1/statuses/home_timeline.json". I also used your suggestion of moving NSLog above the completion handler. Nothing is being printed in the NSLog I've tried adding another NSLog("It should appear") above the other one logging data, and the "it should appear" one did not show either.