Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging JSON Twitter Example #24

Open
prnk28 opened this issue Dec 13, 2014 · 2 comments
Open

Logging JSON Twitter Example #24

prnk28 opened this issue Dec 13, 2014 · 2 comments

Comments

@prnk28
Copy link

prnk28 commented Dec 13, 2014

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
Copy link
Owner

rsieiro commented Dec 15, 2014

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
Copy link
Author

prnk28 commented Dec 17, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants