怎么用JS写个发帖程序?

in #cn5 years ago (edited)


(Image Source: Pixabay)

有没有好奇很多每日自动发的统计贴是怎么实现的?

如果没有,那不要往下看了:D

之前在怎么用JS写个召唤机器人?介绍过一个用于回复帖子的function:



steem.broadcast.comment (
    private_posting_wif,  //发帖密钥
    parent_author,        // 如果是发帖留空
    parent_permlink,      // 主标签
    author,               // 作者
    permlink,             // permlink
    title,                // 标题
    body,                 // 内容
    json_metadata         // json
)

其实回复和发帖都用的是同一个function,区别在于一些参数的不同。

如果parent_author那一栏留空,说明是发帖。相反,如果parent_author那一栏留的是你要回复的作者的id,说明是回复。

如果你要发帖,可以这样写:

const steem = require('steem');

 steem.broadcast.comment(
        "发帖密钥",
        "",   // 如果是发帖留空
        "test",//主标签
        "steem id",// 作者
        "test-post",// permlink
        "Test Post",//标题
        "TEST",//内容
        {
        tags:['test'],//标签
        app:'bot'
        },
        function(err, result) {
            console.log(err, result);
        });

运行以上代码后,会自动发一篇标题为“Test Post”,内容为“TEST”,标签为“test"的帖子。

把内容,标题,标签修改一下,一个自动发帖程序就这样建好了。是不是非常简单?


STEEM编程系列:

Sort:  

没必要炒这种冷饭吧,steem开发文档比这细多了。
不如开发一个实际能用的小程序也好啊

steem文档写的很糟糕,他没告诉你怎样发帖,怎样回复,只提供function,没给任何注释(所以有人发了sps要改善文档)。虽然你觉得可能没啥用,但是这些都是我最早学steemjs时,一直查找的东西。小卖部就是利用这几个搭配起来完成的。

Posted using Partiko iOS

最近在学vue,js文档也粗看了下,比较全吧,没有深入。

js文档是非常破的,不然他们不会花费每天130sbd来改善。我一般是先开发,然后在查文档,很多东西找不到,并且参数怎么使用也没有说明。

Posted using Partiko iOS

看来村长是要大干一场啊!哈,要紧跟村长的脚步啊

也没有,我也是边学边做。来steem前对js一点都不熟,现在倒是用的熟练了。如果你有兴趣,我们有个steem-drivers兴趣小组,大家一起开发一起学习

Posted using Partiko iOS

!thumbup
恭喜你!您的这篇文章入选 @justyy 今日 (2019-10-08) 榜单 【优秀的文章】, 回复本条评论24小时内领赏,点赞本评论将支持 @dailychina 并增加将来您的奖赏。
@justyy 是CN区的见证人,请支持他,给他投票,或者设置justyy为见证人代理。感谢!@justyy的主要贡献:https://steemyy.com

Congratulations! This post has been selected by @justyy as today's (2019-10-08) 【Good Posts】, Steem On! Reply to this message in 24 hours to get rewards. Upvote this comment to support the @dailychina and increase your future rewards! ^_^

SteemIt 工具、API接口、机器人和教程
SteemIt Tools, Bots, APIs and Tutorial



If you believe what I am doing, please consider a spare vote voting me here, thank you very much indeed.

@justyy - the author of https://SteemYY.com and I have been a Steem Witness for more than a year now.

加油!@ericet
来自鸽子在Marlians的支持。

Support your post (by ACTNEARN Token)
Thank you for sharing, Nice post

Hello ericet!

Congratulations! This post has been randomly Resteemed! For a chance to get more of your content resteemed join the Steem Engine Team

感谢代理1010.49SP 给team-cn! 由于你使用CN作为你的首标签,额外获得2%点赞! 你的帖子获得team-cn 27% 点赞!(如果不想看到这个回复,请回复“取消”)

Support your post (by LEO Token)
Thank you for sharing, Nice post

加油!@ericet
鸽子在mediaofficials支持你。

你今天过的开心吗?欢迎在steemauto里设置跟赞 @cnbuddy 给整个cn区点赞假如我的留言打扰到你,请回复“取消”。



This post has been voted on by the SteemSTEM curation team and voting trail. It is elligible for support from @curie and @minnowbooster.

If you appreciate the work we are doing, then consider supporting our witness @stem.witness. Additional witness support to the curie witness would be appreciated as well.

For additional information please join us on the SteemSTEM discord and to get to know the rest of the community!

Please consider using the steemstem.io app and/or including @steemstem in the list of beneficiaries of this post. This could yield a stronger support from SteemSTEM.

Coin Marketplace

STEEM 0.28
TRX 0.13
JST 0.032
BTC 61372.42
ETH 2928.56
USDT 1.00
SBD 3.66