4th Street Bar Hive-Bar

Hive-Bar Powered by Hive beta-fdb5b5b

Community post

[Steemit javascript api 사용하기 레슨8] 블로그에 포스팅하기

안녕하세요 @fullmi입니다.

오늘은 글을 등록하는 api를 사용해서 steemit에 포스팅 해볼건데요

오늘은 steem-js를 사용해 보겠습니다. steemit api문서에서 제가 못찾아서요

그럼 일단 

<script src="https://cdn.steemjs.com/lib/latest/steem.min.js"></script>

위의 스크립트를 삽입해 주시고요.

아래와 같이 작성해주면 끝입니다.

<!doctype html>
<html lang="en">

<head>
<meta charset="UTF-8">
<title>포스팅 작성하기</title>
<script>

function fn_write() {
/** Configure your account */
var username = 'fullmi';
var postingWif = '개인포스팅키입니다.';


try {
/** Broadcast a post */
var permlink = new Date().toISOString().replace(/[^a-zA-Z0-9]+/g, '').toLowerCase();
steem.broadcast.comment(
postingWif,
'', // 공백으로 남김니다.
'kr', // 메인테그를 적습니다.
username, // 계정을 적습니다.
permlink + '-post', // Permlink를 임의로 생성해 줍니다.
'타이틀입니다.', // Title
'내용부분입니다.', // Body
{ tags: ['kr', 'jjangjjangman'], app: 'busy' }, // Json Metadata
function (err, result) {
if (err)
</span>(<spanstyle="color:#ce9178;">'#content'</span>).<spanstyle="color:#dcdcaa;">html</span>(<spanstyle="color:#4ec9b0;">JSON</span>.<spanstyle="color:#dcdcaa;">stringify</span>(<spanstyle="color:#9cdcfe;">err</span>));</div><div><spanstyle="color:#c586c0;">else</span></div><div><spanstyle="color:#dcdcaa;">alert</span>(<spanstyle="color:#ce9178;">'.'</span>);</div><div><spanstyle="color:#608b4e;">//location.href='/Post/GoStop/Comment?p='+permlink+'-post';</span></div><div><spanstyle="color:#dcdcaa;"></span>(<span style="color: #ce9178;">'#content'</span>).<span style="color: #dcdcaa;">html</span>(<span style="color: #4ec9b0;">JSON</span>.<span style="color: #dcdcaa;">stringify</span>(<span style="color: #9cdcfe;">err</span>));</div><div> <span style="color: #c586c0;">else</span> {</div><div> <span style="color: #dcdcaa;">alert</span>(<span style="color: #ce9178;">'작성했습니다.'</span>);</div><div> <span style="color: #608b4e;">// location.href = '/Post/GoStop/Comment?p='+permlink + '-post';</span></div><div> <span style="color: #dcdcaa;">('#content').html(JSON.stringify(result));
}
}
);
} catch (e) {
console.log(e);
}
}
</script>
</head>

<body>
<div id="content"></div>
<button onclick="fn_write()" >작성하기</button>
</body>

</html>
6 upvotes $0.06

Replies (6)

Review before signing

Posting as . Signing with . Keychain permission: Posting. Hive Keychain will ask you to approve this action next.


  
Technical details

Operation fingerprint: