Python Steem API介绍系列#3 - 发帖回复点赞篇

in #cn7 years ago

下面来说说如何使用Python Steem API进行发帖,留言,以及给帖子点赞。

首先,和前面介绍的读取账户信息和读取已发帖子信息不同的是,这里必须要进行验证才能进行发帖等操作。

首先找到你的WIF

登陆你的Steemit账户后,点"Wallet" -> "Permissions",你会看到"POSTING"下面对应了一串很长的密码,不是这个,再点下"SHOW PRIVATE KEY",你会看到一个数字5开头的密码,这就是下面操作需要的密码了。下面的发帖,留言以及Upvote等操作只需要这个POSTING密码就够了。

创建Steem类对象

from steem import Steem

wif = {
    "posting": "复制你刚才看到的密码到这里"
}
steem = Steem(keys=wif)

发个测试帖子

p = steem.post("python API test", "test posting", author='yuxi', tags="test")
print (p)

这里需要注意帖子不要乱发喔,建议只发送到测试标签"test"下,否则可能会被大鲸踩喔。。。

测试一下回复功能

其实在Steem中,回复也是一个帖子,只不过比较特殊而已,回复没有标题。因此在进行回复的时候,也是用的post这个方法:

p = steem.post(title='', body='test commenting', author='yuxi', reply_identifier='@yuxi/python-api-test')

这是测试完发帖和回复后的屏幕截图:

测试一下顶帖Upvote功能

正好今天看到 @peterchen145 这篇文章不错,省了我手工顶了,直接在程序中实现:

steem.vote('@peterchen145/yoyow-pressone', 100.00, 'yuxi')

当然你也可以撤销顶帖,把那个100.00换成负数,比如:-100.00,就会撤消你刚顶过的帖子。

关于这些API使用的一些想法

除了上面介绍的三种功能之外,还有很多有意思的操作,比如:设定留言的回复功能,感觉可以通过这些API实现一个类似微信公共平台的自动回复功能。如果把这些功能组合起来,很容易写出一个自动顶帖,回复,甚至发帖的机器人来。

但是,任何好的技术都是双刃剑,关键看你是怎样来使用。我非常赞同 @tumutanzi 在一篇文章中所说的,要用心来写作,再高级的机器人也只能是冷冰冰的机器人,也许它永远无法懂得怎样去融入一个由一个个活生生的人组成的Steemit社区。

https://steemit.com 首发。非常感谢阅读,欢迎FOLLOW和Upvote @yuxi 激励我创作更多更好的内容。

Sort:  

Upvoted. I'm going to resteem this now :)

老哥 下一篇可不可以说说怎么用数据库查询各个资料 比如排行榜,亦或是 cntag下发帖最多等等

谢谢你的建议,在计划中。。。

那真是太棒了,我是小白 完全不懂数据库语句,不过我想肯定是一些固定的语句格式,坐等老哥的分享

哈哈,一定努力

Congratulations @yuxi! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the total payout received

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!

多谢!正需要这个教程

不客气。。。

This post has received a 2.83 % upvote from @booster thanks to: @yuxi.

Congratulations @yuxi! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of upvotes

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!

谢谢分享!

对于我这样的新人非常有用,谢谢

怎么查询自己账户的 Resource Credits 呢

Coin Marketplace

STEEM 0.17
TRX 0.13
JST 0.027
BTC 59727.23
ETH 2674.33
USDT 1.00
SBD 2.44