domande brevi:Twitter Application-Solo Auth con "portatore Token"
ho generato un token di accesso e un token di accesso segreto a apps.twitter.com per la mia applicazione. Come li uso per inviare una richiesta a https://api.twitter.com/1.1/statuses/user_timeline.json
?
Che cosa è un token bearer compreso di?? È il token di accesso o il token di accesso ? O una codifica dei due?
po 'di contesto:
Sto cercando di fare una domanda che scarica tweets dal mio twitter timeline, senza che l'utente app dover autenticarsi con il proprio account Twitter. Capisco che devo utilizzare l'autenticazione Application-Solo, e che la documentazione (https://dev.twitter.com/docs/auth/application-only-auth) afferma che ho bisogno di usare una chiave consumatori and Secret consumatori richiedere un portatore Token. Ma se ho già generato il token al apps.twitter.com utilizzando il pulsante generare:
sicuramente posso solo hardcode questi nel mio app e passaggio loro come il segnalino del portatore in qualche modo? Ti piace questa mi aspetto:
#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);
Grazie in anticipo per le risposte e aiuto!
Kyle
P.S. Ho guardato a STTwitter, ma penso che sia un po 'inutile usarlo quando quello che sto cercando di ottenere è così semplice (almeno sembra semplice passare solo il token pre-generato a me comunque) ...
per l'autenticazione app-only, non è necessario il token di accesso e il segreto dei token di accesso, solo la chiave del consumatore e il segreto del consumatore sono adeguati. Puoi recuperare i tweet per tutti gli utenti i cui tweet non sono protetti. Considerare i limiti di velocità in considerazione. – Vishal
Grazie a @Vishal. Ho ragione nel dire che usi la chiave del consumatore e il segreto per [richiesta] (https://dev.twitter.com/docs/api/1.1/post/oauth2/token) un token al portatore? Il token al portatore è completamente diverso dai token generati su apps.twitter.com? – kylejm
onestamente, ho dimenticato e attualmente non mi interessa la modalità dalla prospettiva dell'app, quindi spero che qualcuno più familiare possa rispondere. – Vishal