You are viewing a single comment's thread from:

RE: (Part 5)Tutorial On Steem/SteemConnect JS Retrieve And Comment The Last Post @steemconnect pt5

in #utopian-io6 years ago (edited)

Hi, and thanks for the tuts. I stumbled upon your post today while trying to build my own webapp using SteemConnect but with React.

So far so good, I can vote using my webapp. The only problem I'm having is trying to post a comment. To be precise, I don't intend to make a new post, all I want to do is make a comment on an existing post. Every time I'm trying to use the api.comment function, it's returning me with a cryptic 401 error.

I've consulted the steemconnect documentation here https://www.npmjs.com/package/steemconnect which is absolutely terrible since it doesn't explain anything at all on the needed parameters.

So, I'm really asking you if you can help me here and clarify the parameters I need? (An example response e.g) I'll appreciate it.

Here's the function in question:
api.comment(parentAuthor, parentPermlink, author, permlink, title, body, jsonMetadata, function (err, res) {
console.log(err, res)
});

Do I need all of the parameters for a simple comment? I see that you passed author twice, and skipped on a few, and to be honest, I'm quite confused by what you're doing.

Anyway, thanks in advance. I'm really looking forward to solving this.

Sort:  

Hi! I am sorry if it was not clear to you. I completely agree with you that the documentation is really poor and not very helpful! Seems like every developer develop their workarounds for the lack of information.
The complete function to post a comment is:

api.comment(parentAuthor, parentPermlink, author, permlink, title, body, jsonMetadata, function (err, res) {
  console.log(err, res)
});

I have inserted author twice because I knew I was going to comment my own post since I was the only one using the testing platform. Now that I look back I realize it was bad for the didactics.

The parameters that I left blank with "" are jsonMetadata and title.
jsonMetadata: Is extra data that won't be used by Steemit or blogging, but are useful for other applications, such as SteemMonsters. It is a piece of JSON code that is stored but not executed by default by the Steem nodes, only by the applications/nodes that are actually looking to execute that in that context.
title: comments on Steemit don't need a title, only posts do, so I skipped that

The full implementation of that piece of code from this class is:
https://github.com/igormuba/steemhere/blob/class5/js/myscript5.js

Hello and thanks for the reply, I've ran your code and it actually works. But I've copied and pasted the same piece of code in mine, and strangely, I'm still getting a sc2-sdk null error.

Frankly, I'm quite baffled by what's going on. Here's my arrow function, and the data I've inputted.

submitComment = () => { SteemConnect.comment("eaudebla", "crowthelegendvrreview-mdnmolwle9", "eaudebla", "re-crowthelegendvrreview-mdnmolwle9", "", "this is a test", "", function (err, res) { console.log(err, res); }); } I

The function seems right. Did you initialize and log into SteemConnect?
The code for that is here
https://github.com/igormuba/steemhere/blob/class5/js/myscript.js
I empalia that on the previous tutorials, but maybe my didactics were not good enough at that time.
Also, make sure you have the package with the dependencies set
https://github.com/igormuba/steemhere/blob/class5/package.json

Yes, I already logged on steemconnect. I also have the dependencies installed. I’m going to upload my code on GitHub so maybe someone can have a look. Sorry to disturb, but I’m literally losing sleep over this. If you know anyone else who has worked on steemconnect, let me know. The scarcity of people using it is a problem.

EDIT: Here's my code in question
https://github.com/ChilledMatter/AkibaSteem

My comment function is under https://github.com/ChilledMatter/AkibaSteem/blob/master/src/components/PostDetail.js

This is really strange. I have got similar problem as only api.me function works. When I am trying to vote or post a comment I get 401 response...

The guy over at steemconnect's github page managed to fix it!

Just authorize your app here.

https://app.steemconnect.com/authorize/@steemconnect