【发布时间】:2020-08-14 12:42:57
【问题描述】:
我一直在浏览 twitter api 文档,但我不明白,它使用了一种叫做 curl 的东西。 turl 和 Idk 如果需要,但这里是文件所说的,
资源网址为:https://api.twitter.com/1.1/statuses/update.json
curl -XPOST
--url 'https://api.twitter.com/1.1/statuses/update.json?status=hello'
--header 'authorization: OAuth
oauth_consumer_key="oauth_customer_key",
oauth_nonce="generated_oauth_nonce",
oauth_signature="generated_oauth_signature",
oauth_signature_method="HMAC-SHA1",
oauth_timestamp="generated_timestamp",
oauth_token="oauth_token",
oauth_version="1.0"'
而 twurl 选项是
$ twurl -d 'status=Test tweet using the POST statuses/update endpoint' /1.1/statuses/update.json
有没有办法让这与 python 请求一起工作/用我现有的 python 代码实现它,或者有一种更简单的方法可以做到这一点,感谢任何帮助
【问题讨论】:
-
“有没有办法让这与 python 请求一起工作”——当然。只需从
curl命令中提取相关设置即可。它非常易读:-XPOST只是意味着它正在发送一个 POST 请求。我希望--url和--header是不言自明的。