Twitter API using getdata

조회 수: 2 (최근 30일)
Xymbu
Xymbu 2022년 2월 28일
답변: Xymbu 2022년 3월 1일
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
Ive J
Ive J 2022년 2월 28일
편집: Ive J 2022년 2월 28일
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 2022년 2월 28일
The first one worked thank you!

댓글을 달려면 로그인하십시오.

채택된 답변

Xymbu
Xymbu 2022년 3월 1일
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by