X(Twitter)にて自分のブックマークを取得する
https://github.com/trevorhobenshield/twitter-api-client を利用する。自分のアカウントを操作するためにクッキーから情報を抜き出す必要がある。
X の API は Free プランだとブックマーク取得ができない。Basic か Pro が必要。安い Basic プランでも月100ドル必要
code:json
{'client_id': '000000000', 'detail': 'When authenticating requests to the Twitter API v2 endpoints, you must use keys and tokens from a Twitter developer App that is attached to a Project. You can create a project via the developer portal.', 'registration_url': 'https://developer.twitter.com/en/docs/projects/overview', 'title': 'Client Forbidden', 'required_enrollment': 'Appropriate Level of API Access', 'reason': 'client-not-enrolled', 'type': 'https://api.twitter.com/2/problems/client-forbidden'}
解決策
code:python
import httpx
from pprint import pprint
from twitter.account import Account
cookies = {
"ct0": "",
"auth_token": "",
}
client = httpx.Client(cookies=cookies)
account = Account(session=client)
b = account.bookmarks(limit=3)
pprint(b)
account.bookmarks() は limit を指定しないとすべてのブックマークを取得しようとする。
https://github.com/trevorhobenshield/twitter-api-client/blob/35c2d2cda78ef90232553cbad6cff33f41fae652/twitter/account.py#L455C56-L455C65
#やりたい