WizardFactory / BlogSyncer

one write posting all of the world
Apache License 2.0
3 stars 10 forks source link

JUS-38: twitter 사용자 기본 정보와 글 목록 가지고 오기. #8

Closed kimalec closed 9 years ago

kimalec commented 9 years ago

twitter 사용자 기본 정보와 글 목록 가지고 오기. https://dev.twitter.com/docs/api https://github.com/desmondmorris/node-twitter

kimalec commented 9 years ago

Sean Kim added a comment - 26/Nov/14 9:18 AM _pushPostsToBlogs 에서 recvPosts.posts가 undefined 되는 상황으로 서비스가 멈춤 undefined에 대한 예외처리 필요 kakao.js에서도 에러 발생으로 서비스가 멈춤

TypeError: Cannot read property 'providers' of null
    at Promise.<anonymous> (/Users/mis2010/workjs/BlogSyncer/routes/kakao.js:336:25)
    at Promise.<anonymous> (/Users/mis2010/workjs/BlogSyncer/node_modules/mongoose/node_modules/mpromise/lib/promise.js:177:8)
    at Promise.emit (events.js:95:17)
    at Promise.emit (/Users/mis2010/workjs/BlogSyncer/node_modules/mongoose/node_modules/mpromise/lib/promise.js:84:38)
    at Promise.fulfill (/Users/mis2010/workjs/BlogSyncer/node_modules/mongoose/node_modules/mpromise/lib/promise.js:97:20)
    at Object.cb (/Users/mis2010/workjs/BlogSyncer/node_modules/mongoose/lib/query.js:1146:30)
    at Object._onImmediate (/Users/mis2010/workjs/BlogSyncer/node_modules/mongoose/node_modules/mquery/lib/utils.js:137:16)
    at processImmediate [as _immediateCallback] (timers.js:336:15)

예외처리함 twitter 로그인시 아래 에러 발생

Error: Not Found : /twitter/bot_bloglist?providerid=mis2010&userid=547494dd67b2a4000029c84f
    at Layer.app.use.res.render.message [as handle] (/Users/mis2010/workjs/BlogSyncer/app.js:112:15)
    at trim_prefix (/Users/mis2010/workjs/BlogSyncer/node_modules/express/lib/router/index.js:240:15)
    at /Users/mis2010/workjs/BlogSyncer/node_modules/express/lib/router/index.js:208:9
    at Function.proto.process_params (/Users/mis2010/workjs/BlogSyncer/node_modules/express/lib/router/index.js:269:12)
    at next (/Users/mis2010/workjs/BlogSyncer/node_modules/express/lib/router/index.js:199:19)
    at next (/Users/mis2010/workjs/BlogSyncer/node_modules/express/lib/router/index.js:176:38)
    at next (/Users/mis2010/workjs/BlogSyncer/node_modules/express/lib/router/index.js:176:38)
    at next (/Users/mis2010/workjs/BlogSyncer/node_modules/express/lib/router/index.js:176:38)
    at next (/Users/mis2010/workjs/BlogSyncer/node_modules/express/lib/router/index.js:176:38)
    at next (/Users/mis2010/workjs/BlogSyncer/node_modules/express/lib/router/index.js:176:38)

twitter의 기본정보가 저장되지 않음. 로그인시 가져와서 sites db에 저장해야 됨

 db.sites.find()  
{ "_id" : ObjectId("5474939588de6c0000e42e08"), "userId" : ObjectId("5474939588de6c0000e42e06"), "sites" : [ { "_id" : ObjectId("5474939688de6c0000e42e0c"), "blogs" : [ ], "provider" : { "providerName" : "tistory", "accessToken" : "5be1fa5c74f2f3308627f147fde48538_ca739aa78721f1bcd59fbbb65087a321\n", "providerId" : "551071", "displayName" : "mis2010@daum.net" } } ], "__v" : 1 }
{ "_id" : ObjectId("547494dd67b2a4000029c851"), "userId" : ObjectId("547494dd67b2a4000029c84f"), "sites" : [ ], "__v" : 0 }
{ "_id" : ObjectId("547495c067b2a4000029c857"), "userId" : ObjectId("547495c067b2a4000029c855"), "sites" : [ { "_id" : ObjectId("547495c167b2a4000029c85b"), "blogs" : [ { "blog_id" : "72408697", "blog_title" : "khkim2010", "blog_url" : "http://khkim2010.wordpress.com", "_id" : ObjectId("547495c167b2a4000029c85c") }, { "blog_id" : "72408697", "blog_title" : "khkim2010", "blog_url" : "http://khkim2010.wordpress.com", "_id" : ObjectId("547495c167b2a4000029c85d") } ], "provider" : { "providerName" : "Wordpress", "accessToken" : "3Y2%8#poJbJa%&&j8Jv%M5!C*82Je1wAeWJ^VK%09F8fM3tOmEY!mlLBq9^LvK^e", "providerId" : "72408697", "displayName" : "khkim2010" } } ], "__v" : 2 }

bot_bloglist 에 대한 처리가 필요함

Sean Kim added a comment - 28/Nov/14 9:35 AM https://blog.twitter.com/2014/rendering-tweets-with-angularjs-and-nodejs statuses/user_timeline 대신에 statuses/home_timeline.json 으로 변경해서 얻으면 될듯 /users/show.json or /statuses/show/' + escape(id) + '.json 를 통해 사용자 기본정보를 얻어오면 될듯.

Sean Kim added a comment - 30/Nov/14 6:37 AM https://github.com/twitterdev/sample-angular-node 를 참조하는 게 빠르겠음 디자인 요소 이쁨, 추후에 이런식으로 모아보기를 구성하는 것도 괜찮을 듯 하지만 UI는 jade가 아닌 ejs로 구성되어 있음

package.json에 "twit": "^1.1.18” 추가 이것은 oauth를 위한 것인가? 만약 그렇다면 나중에 제거 필요함

Sean Kim added a comment - 30/Nov/14 9:44 AM twitter에 대한 blog_bot 이 동작하지 않음 db 삭제 후 bot_bloglist 가 호출되나 에러 발생

GET /twitter/authorized?oauth_token=rlLM47k90yXgkTEqkMozw7gKquqcEQMY&oauth_verifier=fKZEgKQO1vDgxv7E4eJi32V3zTISBQHo 302 1630ms - 60b
info: make new siteDb for user._id=5479e95568d3a969161b01c9
debug: find or create blog db of user 5479e95568d3a969161b01c9
debug: url=http://www.justwapps.com/twitter/bot_bloglist?providerid=mis2010&userid=5479e95568d3a969161b01c9
info: make new groupDb for user._id=5479e95568d3a969161b01c9
GET / 304 2ms
info: make new historyDb for user._id=5479e95568d3a969161b01c9
info: make new postdb for user._id=5479e95568d3a969161b01c9
debug: Twitter : /bot_bloglist?providerid=mis2010&userid=5479e95568d3a969161b01c9 : this is called by bot
debug: Twitter : /bot_bloglist?providerid=mis2010&userid=5479e95568d3a969161b01c9 : this is called by bot
error: Fail to find providers

/Users/mis2010/workjs/BlogSyncer/routes/twitter.js:183
            consumer_key: config.consumerKey,
                                ^
TypeError: Cannot read property 'consumerKey' of undefined
    at userTimeline (/Users/mis2010/workjs/BlogSyncer/routes/twitter.js:183:33)
    at Promise.<anonymous> (/Users/mis2010/workjs/BlogSyncer/routes/twitter.js:272:9)
    at Promise.<anonymous> (/Users/mis2010/workjs/BlogSyncer/node_modules/mongoose/node_modules/mpromise/lib/promise.js:177:8)
    at Promise.emit (events.js:95:17)
    at Promise.emit (/Users/mis2010/workjs/BlogSyncer/node_modules/mongoose/node_modules/mpromise/lib/promise.js:84:38)
    at Promise.fulfill (/Users/mis2010/workjs/BlogSyncer/node_modules/mongoose/node_modules/mpromise/lib/promise.js:97:20)
    at /Users/mis2010/workjs/BlogSyncer/node_modules/mongoose/lib/query.js:1394:13
    at model.Document.init (/Users/mis2010/workjs/BlogSyncer/node_modules/mongoose/lib/document.js:250:11)
    at completeOne (/Users/mis2010/workjs/BlogSyncer/node_modules/mongoose/lib/query.js:1392:10)
    at Object.cb (/Users/mis2010/workjs/BlogSyncer/node_modules/mongoose/lib/query.js:1151:11)
30 Nov 00:42:13 - [nodemon] app crashed - waiting for file changes before starting...

Sean Kim added a comment - 30/Nov/14 10:10 AM 아래 에러 발생

error: Fail to find providers
/Users/mis2010/workjs/BlogSyncer/routes/twitter.js:274
        log.debug(p.providerId);
                   ^
TypeError: Cannot read property 'providerId' of undefined
    at Promise.<anonymous> (/Users/mis2010/workjs/BlogSyncer/routes/twitter.js:274:20)
    at Promise.<anonymous> (/Users/mis2010/workjs/BlogSyncer/node_modules/mongoose/node_modules/mpromise/lib/promise.js:177:8)
    at Promise.emit (events.js:95:17)
    at Promise.emit (/Users/mis2010/workjs/BlogSyncer/node_modules/mongoose/node_modules/mpromise/lib/promise.js:84:38)
    at Promise.fulfill (/Users/mis2010/workjs/BlogSyncer/node_modules/mongoose/node_modules/mpromise/lib/promise.js:97:20)
    at /Users/mis2010/workjs/BlogSyncer/node_modules/mongoose/lib/query.js:1394:13
    at model.Document.init (/Users/mis2010/workjs/BlogSyncer/node_modules/mongoose/lib/document.js:250:11)
    at completeOne (/Users/mis2010/workjs/BlogSyncer/node_modules/mongoose/lib/query.js:1392:10)
    at Object.cb (/Users/mis2010/workjs/BlogSyncer/node_modules/mongoose/lib/query.js:1151:11)
    at Object._onImmediate (/Users/mis2010/workjs/BlogSyncer/node_modules/mongoose/node_modules/mquery/lib/utils.js:137:16)

twitter를 Twitter로 findProvider했음 ㅠㅠ

Sean Kim added a comment - 02/Dec/14 9:34 AM UserTimeline 데이터 얻어온

created_at=Thu Aug 16 06:23:39 +0000 2012, id=235985154416443400, id_str=235985154416443392, text=만화로 영상통화하는 앱 ‘눈길’ - 지디넷코리아 http://t.co/EfKjK3Xz, source=<a href="https://dev.twitter.com/docs/tfw" rel="nofollow">Twitter for Websites</a>, truncated=false, in_reply_to_status_id=null, in_reply_to_status_id_str=null, in_reply_to_user_id=null, in_reply_to_user_id_str=null, in_reply_to_screen_name=null, id=86051098, id_str=86051098, name=KwangHo Kim, screen_name=mis2010, location=, profile_location=null, description=, url=null, urls=[], protected=false, followers_count=16, friends_count=12, listed_count=0, created_at=Thu Oct 29 12:05:39 +0000 2009, favourites_count=4, utc_offset=null, time_zone=null, geo_enabled=true, verified=false, statuses_count=32, lang=en, contributors_enabled=false, is_translator=false, is_translation_enabled=false, profile_background_color=C0DEED, profile_background_image_url=http://abs.twimg.com/images/themes/theme1/bg.png, profile_background_image_url_https=https://abs.twimg.com/images/themes/theme1/bg.png, profile_background_tile=false, profile_image_url=http://pbs.twimg.com/profile_images/1189405967/myProfileImage_normal.jpg, profile_image_url_https=https://pbs.twimg.com/profile_images/1189405967/myProfileImage_normal.jpg, profile_link_color=0084B4, profile_sidebar_border_color=C0DEED, profile_sidebar_fill_color=DDEEF6, profile_text_color=333333, profile_use_background_image=true, default_profile=true, default_profile_image=false, following=false, follow_request_sent=false, notifications=false, geo=null, coordinates=null, place=null, contributors=null, retweet_count=0, favorite_count=0, hashtags=[], symbols=[], user_mentions=[], urls=[url=http://t.co/EfKjK3Xz, expanded_url=http://www.zdnet.co.kr/news/news_view.asp?artice_id=20120816120157, display_url=zdnet.co.kr/news/news_view…, indices=[27, 47]], favorited=false, retweeted=false, possibly_sensitive=false, lang=ko, created_at=Fri Jun 15 04:59:33 +0000 2012, id=213495942236745730, id_str=213495942236745729, text=앱 출시! 헬로툰2
탱고, 카카오톡, 페이스북기능을 하나의 앱에서 쓸수 있는 소셜 앱이구여
안드로이드 아이폰 둘다 지원하구여
'헬로툰'으로 검색하세여~
.....

사용자 기본정보는 아직 얻어오지 못함 blog bot이 동작하는 순서에 따라 처리가 필요 사용자 기본정보는 어떤 것들을 db에 저장해야하는가?

Sean Kim added a comment - 04/Dec/14 9:35 AM displayName 을 userName에서 profile.displayName으로 변경 사용자 기본정보를 위한 에러 발생 아래 functions 모두 작동 안됨?????

 /*
        twitter.get('/statuses/show.json', {id:86051098, include_entities:true}, function(data, res) {
            log.debug("status =>" +  data);
            //console.log(util.inspect(data), res.statusCode);
        });
        */
        /*
        twitter.get('/statuses/show/86051098.json', {include_entities:true}, function(data, res) {
            log.debug("status =>" +  data);
        });
        */
        /*
        twitter.get('/users/show.json', {screen_name:'KwangHo Kim'}, function(data, res) {
            //console.log(util.inspect(data), res.statusCode);
            log.debug("status =>" +  data);
        });
        */
        api_url = "https://api.twitter.com/1.1/users/show.json?user_id=86051098";

에러 발생 debug: https://api.twitter.com/1.1/users/show.json?user_id=86051098 debug: API error: 401 undefined

Sean Kim added a comment - 07/Dec/14 1:27 AM twit, twitter api 동작하지 않음 OAuth npm으로 기본정보 동작함 'SSL is required' error 가 발생하였지만 http->https로 해결 http://devhike.blogspot.kr/2013/02/using-nodejs-oauth-module-to.html

Sean Kim added a comment - 07/Dec/14 6:02 AM bot_bloglist, bot_post_count 처리 bot_posts를 위해서는 twitter가 페이지 개념이 없기에 max_id, since_id를 잘 이용해야함 https://dev.twitter.com/rest/public/timelines

Sean Kim added a comment - 07/Dec/14 7:01 AM count만 넘겼을때 동작하지만 max_id를 넣으면 twit들을 가져오지 못함 _addPostsFromNewBlog에서 twitter일 때는 내림차순으로 동작시킴

Sean Kim added a comment - 07/Dec/14 7:08 AM https://dev.twitter.com/rest/tools/console 로 max_id 동작유무를 확인해야함

Sean Kim added a comment - 14/Dec/14 9:44 AM max_id 는 개수를 나타내는 것이 아니라 post_id를 나타내는 것임 20개씩 얻기 위해서는 21개를 얻어, 20개를 디비에 저장하고, 21번째 id를 가지고 있다가 more 시 max_id로 지정하여 가져와야 될 것임.

Sean Kim added a comment - 15/Dec/14 9:37 AM max_id를 위해서는 _recursiveGetPosts를 쓰는 루틴으로 변경 kakao처럼 last_id를 이용한 getPost를 사용해야하지만 twitter는 max_id(=last_id) 부터 post를 get한다. 그러므로 계속 반복적으로 마지막 post를 가져오는 에러 발생. 예외처리를 하던가 아니면 _recursiveGetPostsForTwitter function을 새로 만들어야 될 듯 보임

Sean Kim added a comment - 15/Dec/14 9:57 AM request 한 max_id와 get 한 id가 동일하고, cnt가 1이면 reculsive를 멈추자. 멈출때는 router에서 send_post에 flag를 넣거나, reculsive func에서 처리하든가,,,

Sean Kim added a comment - 18/Dec/14 8:39 AM 버그로 인하여 reculsive를 멈추는 작업을 반복하니 twitter api가 result를 못 얻어옴... 서버의 부하를 주는 블랙 유저가 된 것인가????? 시간이 좀 지나면 풀어줄것인가 아니면 영원히 풀어주지 않을 것인가?.... 내일 다시 해봐야겠음...

Sean Kim added a comment - 18/Dec/14 8:53 AM 5분 정도 후에 다시 시도 하니 글 얻어옴. 현재상태는 reculsive 멈추는 조건을 만족함 max_id(last_id)가 두 번씩 호출 됨

Sean Kim added a comment - 18/Dec/14 8:58 AM 두번 호출 되는 문제와 Twitter 모아보기는 이슈 분리해야겠음. 한 이슈 너무 텀이 김 Merge 해야 되는 데 겁남 너무 이전 소스로 작업해놔서리 ㅋㅋ

Sean Kim added a comment - 21/Dec/14 8:14 AM Merge 완료 후 수정처리 pull request 하므로 resolve 처리함

Sean Kim added a comment - 21/Dec/14 8:19 AM 텀이 너무 길었음.. 이슈를 쪼갤 필요가 있었음 전반적인 이해가 부족했으나 twitter를 하면서 이해도는 증가된 것 같음

Alec Kim added a comment - 21/Dec/14 10:41 PM build failing 발생했습니다. code review도 create해주세요.

Sean Kim added a comment - 22/Dec/14 6:11 AM package.json merge 시에 oauth와 q 사이에 , 가 빠져서 npm install error가 남 수정후 pull request

Sean Kim added a comment - 22/Dec/14 6:11 AM build 오류 수정함

Sean Kim added a comment - 22/Dec/14 6:13 AM code review create 하였음