Short questions:
I've generated an Access Token and an Access Token Secret at apps.twitter.com for my application. How do I use them to send a request to https://api.twitter.com/1.1/statuses/user_timeline.json
?
What is a Bearer Token comprised of? Is it the Access Token or the Access Token Secret? Or an encoding of the two?
Bit of context:
I'm trying to make an application that downloads tweets from my twitter timeline without the app user having to authenticate with their twitter account. I understand that I must use Application-Only authentication, and that the documentation (https://dev.twitter.com/docs/auth/application-only-auth) states that I need to use a Consumer Key and Consumer Secret to request a Bearer Token. But if I've already generated the tokens at apps.twitter.com using the generate button:
surely I can just hardcode these into my app and pass them along as the Bearer Token in some way? Like this I'd expect:
#define kTwitterBearerToken @"123456"
NSURL *twitterFeedURL = [NSURL URLWithString:@"https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=kylejm_&count=10"];
NSMutableURLRequest *URLRequest = [NSMutableURLRequest requestWithURL:twitterFeedURL];
[URLRequest setHTTPMethod:@"POST"];
[URLRequest setValue:[NSString stringWithFormat:@"Bearer %@", kTwitterBearerToken] forHTTPHeaderField:@"Authorization"];
NSURLResponse *URLResponse;
NSError *URLerror;
NSData *tweetData = [NSURLConnection sendSynchronousRequest:URLRequest returningResponse:&URLResponse error:&URLerror];
NSError *JSONError;
NSArray *tweets = [NSJSONSerialization JSONObjectWithData:tweetData options:0 error:&JSONError];
NSLog(@"%@", tweets);
Thanks in advance for answers and help!
Kyle
P.S. I've looked at STTwitter, but think that it's a bit unnecessary to use it when what I'm trying to achieve is so simple (at least it seems simple to just pass the pre-generated token to me anyway)...