Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add naver blog write api #291

Open
kimalec opened this issue Jun 3, 2015 · 2 comments
Open

add naver blog write api #291

kimalec opened this issue Jun 3, 2015 · 2 comments
Assignees

Comments

@kimalec
Copy link
Member

kimalec commented Jun 3, 2015

naver에서 제공하는 글쓰기 api 적용

http://developer.naver.com/wiki/pages/NaverBlogAPI

@kimalec kimalec changed the title naver oauth, write api 적용. add naver blog write api Jun 3, 2015
@pokers
Copy link
Contributor

pokers commented Jul 4, 2015

  • 완료된 작업
    • login 기능 완료
    • 글 올리기 기능 완료(사진 제외)
  • 해야할 작업
    • 사진 올리기
    • 네이버 글 가져오기
    • 글 올릴때 옵션 지정하기

@pokers
Copy link
Contributor

pokers commented Jul 13, 2015

  • 사진 올리기
    • 사진올리기 기능 검증 완료.
    • 아래 코드는 naver에 사진 올리기 예제 코드.
    • 여러개의 사진 및 여러개의 사진이 정상적인 위치(위치 tag)에 올라가는지 확인 필요.
router.post('/bot_posts/new/:blog_id', function (req, res) {
    var userId = userMgr.getUserId(req, res);
    if (!userId) {
        return;
    }
    var meta = {"cName":NAVER_PROVIDER, "userId":userId, "url":req.url};
    log.info("+", meta);

    var blogId = req.params.blog_id;
    var botPost = req.body;
    var newForm = new formData();

    log.info('image path :' + __dirname + '/naver.png');
    newForm.append('image', fs.createReadStream(__dirname + '/naver.png'));

    var testData = '<div>Hello world This is image example. <img src="#0" />Fig. 1-1Good day! </div>';
    newForm.append('contents', testData);
    newForm.append('title', 'TEST Image');

    userMgr.findProviderByUserId(userId, NAVER_PROVIDER, blogId, function (err, user, provider) {
        var apiUrl = NAVER_API_URL + "/writePost.json";
        log.debug(apiUrl, meta);
        newForm.getLength(function(err, length){
            log.info('content length : ' + length);
            var req = request.post(apiUrl, {
                json: true,
                multipart: true,
                headers: {
                    "Authorization": "Bearer " + provider.accessToken,
                }
            }, function (err, response, body) {
                if(err) {
                    log.info('post ERROR!!!!');

                    return;
                }

                log.info('posted');
            });

            req._form = newForm;
            //req.setHeader('content-length', length);
            //req.setHeader('enctype', 'multipart/form-data');
            //req.setHeader('content-type', 'image/jpeg');
        });
    });
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants