コンソールでは
C:\Users\Desktop>node test.js @TwitterJP [ { created_at: 'Fri Jan 08 09:28:51 +0000 2016', id: 685392711499661300, id_str: '685392711499661312', text: 'TwitterJPからの #クリスマスボックス の当選者の皆さん。お待たせしまし た。本日プレゼントを配送いたしましたので、数日中にお手元に届くと思われます。著名 人の方々からのプレゼントの当選者の皆さんはもう少しお待ちください。\nhttps://t.co /h2b5y2NqFP', source: '<a href="http://twitter.com" rel="nofollow">Twitter Web Client</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, user: { id: 7080152, id_str: '7080152', name: 'TwitterJP', screen_name: 'TwitterJP', location: '東京都中央区', description: '日本語版Twitter公式アカウントです。サービスに関しては https ://t.co/mfQkUQLUhe をご参照ください。', url: 'https://t.co/A9dNuL0CCa', entities: [Object], protected: false, followers_count: 2090430, friends_count: 114, listed_count: 16482, created_at: 'Tue Jun 26 01:54:35 +0000 2007', favourites_count: 108, utc_offset: 32400, time_zone: 'Tokyo', geo_enabled: false, verified: true, statuses_count: 3587, lang: 'ja', contributors_enabled: false, is_translator: false, is_translation_enabled: false, profile_background_color: 'C0DEED', profile_background_image_url: 'http://pbs.twimg.com/profile_background_im ages/567482719571959809/WwgdnJCP.jpeg', profile_background_image_url_https: 'https://pbs.twimg.com/profile_backgr ound_images/567482719571959809/WwgdnJCP.jpeg', profile_background_tile: true, profile_image_url: 'http://pbs.twimg.com/profile_images/3407356865/62f0d5 3222361fbd2c1fe9889f4cc559_normal.png', profile_image_url_https: 'https://pbs.twimg.com/profile_images/3407356865 /62f0d53222361fbd2c1fe9889f4cc559_normal.png', profile_banner_url: 'https://pbs.twimg.com/profile_banners/7080152/145186 4421', profile_link_color: '0084B4', profile_sidebar_border_color: 'FFFFFF', profile_sidebar_fill_color: 'DDEEF6', profile_text_color: '333333', profile_use_background_image: true, has_extended_profile: true, default_profile: false, default_profile_image: false, following: false, follow_request_sent: false, notifications: false }, geo: null, coordinates: null, place: null, contributors: null, quoted_status_id: 679875462294716400, quoted_status_id_str: '679875462294716416', quoted_status: { created_at: 'Thu Dec 24 04:05:16 +0000 2015', id: 679875462294716400, id_str: '679875462294716416', text: '最後の� #クリスマスボックス は感謝を込めて @TwitterJP から!投票し てくださった方から抽選で各5名様に。 応募規約: https://t.co/N4tBi2HcDv https://t .co/r7HZ0PaMVN \nhttps://t.co/r7HZ0PaMVN', source: '<a href="http://twitter.com" rel="nofollow">Twitter Web Client</ 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, user: [Object], geo: null, coordinates: null, place: null, contributors: null, is_quote_status: false, retweet_count: 246, favorite_count: 301, entities: [Object], favorited: false, retweeted: false, possibly_sensitive: false, lang: 'ja' }, is_quote_status: true, retweet_count: 16, favorite_count: 37, entities: { hashtags: [Object], symbols: [], user_mentions: [], urls: [Object] }, favorited: false, retweeted: false, possibly_sensitive: false, lang: 'ja' } ]
うまくタイムラインを取得できるのですが
fsモジュールを使って,JSON形式に保存しようとすると,
[object Object]
となってしまいます.どうすればコンソールのように出力できるのでしょうか.
###Node.jsプログラム
var params = {screen_name: 'TwitterJP',count:1}; console.log("@"+params.screen_name); T.get('statuses/user_timeline', params, function(error, tweets){ if (!error) { console.log(tweets); fs.appendFileSync('twitter1.txt',tweets + "\n",'utf-8'); } });
回答1件
あなたの回答
tips
プレビュー