简体   繁体   English

如何在Lua中使用OAUTH发送POST请求

[英]How to send a POST request with OAUTH in Lua

So I want to tweet on Twitter by sending a POST request to the Twitter API. 因此,我想通过向Twitter API发送POST请求在Twitter上进行鸣叫。

I have not found a simple way to do this (unless I use a wrapper), and I'm not too experienced with Lua. 我还没有找到一种简单的方法来进行此操作(除非使用包装器),而且我对Lua的使用也不太熟悉。 This is Twitter's own example using curl: 这是Twitter自己使用curl的示例:

$ curl --request POST 
--url 'https://api.twitter.com/1.1/statuses/update.json?
status=Test%20tweet%20using%20the%20POST%20statuses%2Fupdate%20endpoint' 
--header 'authorization: OAuth oauth_consumer_key="YOUR_CONSUMER_KEY",
oauth_nonce="AUTO_GENERATED_NONCE", oauth_signature="AUTO_GENERATED_SIGNATURE",
oauth_signature_method="HMAC-SHA1", oauth_timestamp="AUTO_GENERATED_TIMESTAMP",
oauth_token="USERS_ACCESS_TOKEN", oauth_version="1.0"' 
--header 'content-type: application/json'

But from some wrappers I've seen, it seems that you can use: 但是从我看到的一些包装器中,您似乎可以使用:

consumer_key
consumer_secret
access_token
access_token_secret

I just want a simple way of tweeting without being able to have all of the other API functionality that the Twitter API has. 我只想要一种简单的发推方法,而不能拥有Twitter API所具有的所有其他API功能。 So no wrapper or anything. 因此,没有包装器或任何东西。 Just a simple script, but I can't seem to figure it out. 只是一个简单的脚本,但我似乎无法弄清楚。 Any help is greatly appreciated. 任何帮助是极大的赞赏。

Use a specialized Lua library for Twitter, eg https://github.com/leafo/lua-twitter 对Twitter使用专用的Lua库,例如https://github.com/leafo/lua-twitter

luarocks install https://luarocks.org/manifests/leafo/twitter-dev-1.rockspec

or a more general Lua library for OAuth, eg https://github.com/ignacio/LuaOAuth and do the rest yourself. 或用于OAuth的更通用的Lua库,例如https://github.com/ignacio/LuaOAuth,然后自己完成其余工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM