获取Pocket发送到mastodon
IPFS
Pocket操作
- pip install pocket-api
- https://pypi.org/project/pocket-api/
主要是获取CONSUMER KEY和access token
- 获取CONSUMER KEY
- https://getpocket.com/developer/apps/new
- 设置对应名字和权限,然后得到CONSUMER KEY,名字后面会用到。
- oauth 取得code
- https://getpocket.com/v3/oauth/request,post请求
consumer_key=<consumer_key> redirect_uri=<app_name>:authorizationFinished
- 返回类似:code=
- 激活授权
- 浏览器输入:https://getpocket.com/auth/authorize?request_token=a546cd87-2546-86ea-b213-3d5de4&redirect_uri=<app_name>:authorizationFinished
- 获取access_token
- post请求:https://getpocket.com/v3/oauth/authorize
consumer_key= code=
- 返回access_token=
参考https://getpocket.com/developer/docs/v3/retrieve
p = Pocket(consumer_key='',access_token='') p.retrieve(offset=0,count=5,tag='hk',since=test_timestamp) # 根据返回值读取 resolved_url和resolved_title
发送消息到mastodon
- 获取对应参数:应用 ID,应用密钥,你的访问令牌
- pip install mastodon.py
- https://mastodonpy.readthedocs.io/en/stable/
mastodon = Mastodon( client_id='', client_secret='', access_token = '', api_base_url = 'https://domain' ) mastodon.toot(str) # str为发送文本,其他参数参考docs
定时执行
每天00点定时执行
0 10 * * * python /home/youScript.py
参考
https://getpocket.com/developer/docs/v3/retrieve
https://mastodonpy.readthedocs.io/en/stable/
喜欢我的作品吗?别忘了给予支持与赞赏,让我知道在创作的路上有你陪伴,一起延续这份热忱!
- 来自作者
- 相关推荐