Twitter API using getdata

3 ビュー (過去 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 Center および File ExchangeCall 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