Skip to content

leiqin/twitter-api-test

Repository files navigation

twitter-api-test

一个测试 Twitter API 的命令行小工具

https://dev.twitter.com/apps 上创建应用后, 修改 config.py 中的 consumer_key 和 consumer_secret 为对应的值,就可以使用了。

比如:

./twitter.py -p count=5 -p trim_user=true statuses/home_timeline

就可以获得用户的时间线,具体信息可以参考 Twitter API , 返回的是 JSON 格式,本程序只是简单的把它输出到控制台而已,可以将它重定向到 JSON 文件中:

./twitter.py -p count=5 -p trim_user=true statuses/home_timeline >/tmp/test.json

然后用浏览器或者其他查看 JSON 的工具查看。

第一次使用时,会需要授权,程序会自动打开浏览器,授权之后,就会看到 PIN-Code , 把它输入到控制台,回车即可。

可以参考:Implementing Sign in with TwitterPIN-based authorizationAuthorizing a requestCreating a signature , 生成的 Token 会储存到 config.json 中。

也可以使用 Tokens from dev.twitter.com 生成的 Token ,把对应的 access_token 和 access_token_secret 配置到 config.py 就行了。

(PS: 本程序不自带翻墙功能,请使用 VPN 或其他翻墙工具)

GitHub, GitHub OAuth

Facebook, Graph API, The Login Flow for Web (without JavaScript SDK), Access Tokens

Google, Using OAuth 2.0 for Login,

Google OpenID, OpenID Enabled, python-openid

JSON Web Token (JWT), JSON Web Signature (JWS), Verifying signature in Python

About

A Tool For Test Twitter API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages