How to Broadcast a Comment to a specific user link

in #steemrepo6 years ago (edited)

new-york-1071162_1280.jpg
CC0 Creative Commons Pixabay

Hi everyone today we explain about the possibility to use the Steem Api to broadcast a comment on a specific user post.
I use the comment on the @steemrepo project because our curators choose good quality posts and can make the upvote/comment on a post directly by our discord server:

Immagine.png

We use discord because we take this two var used on the script:

Author: the post author
Permlink: the link of the post author

Requirements


Installing the libraries:

sudo apt-get install nodejs
sudo apt-get install npm
npm install steem --save

Write the Code

var steem = require("steem");
var wifkey = youprivatepostingkey;
var author = postauthor;
var permlink = thelinkoftheposttocommenton;
var author1 = theuserwewillusetocomment;

  steem.broadcast.comment(
    wifkey,
    author, // Parent Author
    permlink, // Parent Permlink
    author1, // Author
    steem.formatter.commentPermlink(author, permlink),
    '', // Title
    'The comment you wanna add on a post' , // Body,
   { tags: ['test'], app: `steemjs/examples` }, // Json Metadata
    function(err, result) {
      console.log(err, result);
    }
  );

Explain the variables

To comment on a specific user post we use the steem.js functions called
"steem.broadcast.comment"
"steem.formatter.commentPermlink"

  • wifkey = the private posting key of the users we are using to comment
  • author = called Parent Author is the author of the post we are commenting on
  • permlink = is exactly the url we are commenting on
  • Author1 = is the username related to the wifkey we are using to comment

Let me do an example:

Imagine you are @yanosh01 and you want to comment this @steemrepo post:

https://steemit.com/steemrepo/@steemrepo/steemrepo-rewarding-undervalued-content-creators

it will be:

  • wifkey = the private posting key of yanosh01
  • author = steemrepo
  • permlink = steemrepo-rewarding-undervalued-content-creators
  • Author1 = yanosh01

If you like what i'm doing, please upvote me as your Witness

https://steemit.com/~witnesses

witness.gif

Sort:  

Coin Marketplace

STEEM 0.28
TRX 0.12
JST 0.032
BTC 65941.77
ETH 3015.51
USDT 1.00
SBD 3.75