Twitter API using getdata

2 visualizaciones (últimos 30 días)
Xymbu
Xymbu el 28 de Feb. de 2022
Respondida: Xymbu el 1 de Mzo. de 2022
How do I add the bearer token in a header using the getdata() function.
an example from the API
curl 'https://api.twitter.com/2/tweets?ids=1204084171334832128&tweet.fields=public_metrics&expansions=attachments.media_keys&media.fields=public_metrics' --header 'Authorization: Bearer $BEARER_TOKEN'
im not sure how to handle the header part
  2 comentarios
Ive J
Ive J el 28 de Feb. de 2022
Editada: Ive J el 28 de Feb. de 2022
What about this?
headers = {'Authorization', ['Bearer ', yourToken]};
options = weboptions('HeaderFields', headers);
res = webread(url, options);
% if that fails, what about this?
res = webwrite(url, headers);
Xymbu
Xymbu el 28 de Feb. de 2022
The first one worked thank you!

Iniciar sesión para comentar.

Respuesta aceptada

Xymbu
Xymbu el 1 de Mzo. de 2022
The suggestion in the comments from Ive J works. I ended up, however, calling the python library requests in order to automate the creation of the Oauth1 authentication. This made it very easy to format.

Más respuestas (0)

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by