views:

544

answers:

2

This is my first web API project, so I hope the solution to this isn't blindingly obvious.

// Contstruct the http request
NSString *urlString = [NSString stringWithFormat:@"http://%@:%@@twitter.com/statuses/user_timeline/%@.xml?count=5", username, password, friend];
NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];

// Recive the data from the synchronous request
NSData *urlData;
urlData = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:nil error:nil];

The results returned from this query look fine except they don't reflect if I've favorited them or not. All tweets return "false", even if the authenticating user has starred them. I'm fairly confident that I'm authenticating correctly as code further down that does require authentication behaves correctly.

+1  A: 

Add a Basic Authentication header field where you specify the username/password. Most libraries have a setCredentials() method though.

dirkgently
There is an NSCredential that I can use to handle authentication, but I don't think that's the problem. Later on in the code I use nearly the same code to post an update to twitter and it works fine.
kubi
I have been bitten by a refresh bug as well as the 100 requests per hour limit. Check if this is the case. For the former, you can try to retrieve the rss and see if that is updated/matches your expectations. Yes the xml and the rss can be out of sync. For the latter, go get some coffee.
dirkgently
Dirk! Thanks, that seems to be what it was.
kubi
A: 

As dirkgently pointed out in the previous post, the XML was out of sync with reality. With no changes to the code at all, things that weren't working this morning were working tonight. Thanks Dirk!

kubi
Great! You can, if you deem fit, mark my answer as accepted. Shameless plug :P
dirkgently