{"id":13474425,"url":"https://github.com/node-modules/weibo","last_synced_at":"2025-06-14T03:07:34.836Z","repository":{"id":62783445,"uuid":"1391391","full_name":"node-modules/weibo","owner":"node-modules","description":"weibo nodejs sdk","archived":false,"fork":false,"pushed_at":"2019-10-04T21:55:21.000Z","size":1030,"stargazers_count":491,"open_issues_count":18,"forks_count":160,"subscribers_count":41,"default_branch":"master","last_synced_at":"2025-06-09T01:44:49.527Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://github.com/fengmk2/node-weibo","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/node-modules.png","metadata":{"files":{"readme":"README.md","changelog":"History.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-02-21T03:24:15.000Z","updated_at":"2025-05-18T01:09:15.000Z","dependencies_parsed_at":"2022-11-06T12:46:13.828Z","dependency_job_id":null,"html_url":"https://github.com/node-modules/weibo","commit_stats":null,"previous_names":["fengmk2/node-weibo"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/node-modules/weibo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-modules%2Fweibo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-modules%2Fweibo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-modules%2Fweibo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-modules%2Fweibo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/node-modules","download_url":"https://codeload.github.com/node-modules/weibo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-modules%2Fweibo/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259752078,"owners_count":22905972,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T16:01:12.257Z","updated_at":"2025-06-14T03:07:33.790Z","avatar_url":"https://github.com/node-modules.png","language":"JavaScript","readme":"# node-weibo [![Build Status](https://secure.travis-ci.org/fengmk2/node-weibo.png)](http://travis-ci.org/fengmk2/node-weibo)\n\n[![NPM](https://nodei.co/npm/weibo.png?downloads=true\u0026stars=true)](https://nodei.co/npm/weibo/)\n\n![logo](https://raw.github.com/fengmk2/node-weibo/master/logo.png)\n\nA [weibo](http://weibo.com)(like [twitter](http://twitter.com)) API SDK, use on browser client and nodejs server.\n\nPlease see the [API Documents](https://github.com/fengmk2/node-weibo/blob/master/api.md) first.\n\n## Supports APIs\n\n * weibo: [http://t.sina.com.cn/](http://weibo.com/)\n * tqq: [http://t.qq.com/](http://t.qq.com/)\n * github: [http://github.com](http://github.com), only `oauth` for now.\n * twitter(unavailable): [http://twitter.com/](http://twitter.com/)\n * facebook(unavailable): [http://facebook.com/](http://facebook.com/)\n * fanfou(unavailable): [http://fanfou.com/](http://fanfou.com/)\n * digu(unavailable): [http://digu.com/](http://digu.com/)\n * tsohu(unavailable): [http://t.sohu.com/](http://t.sohu.com/)\n * t163(unavailable): [http://t.163.com/](http://t.163.com/)\n * plurk(unavailable): [http://plurk.com/](http://plurk.com/)\n\n## Nodejs Install\n\n```bash\n$ npm install weibo\n```\n\n## How to use\n\n`entry.js`\n\n```js\nvar weibo = require('weibo');\n\n// change appkey to yours\nvar appkey = 'your appkey';\nvar secret = 'your app secret';\nvar oauth_callback_url = 'your callback url';\nweibo.init('weibo', appkey, secret, oauth_callback_url);\n\nvar user = { blogtype: 'weibo' };\nvar cursor = {count: 20};\nweibo.public_timeline(user, cursor, function (err, statuses) {\n  if (err) {\n    console.error(err);\n  } else {\n    console.log(statuses);\n  }\n});\n```\n\nDemo on nodejs and browser just the same code.\n\nThanks for [browserify](https://github.com/substack/node-browserify),\nlet us to use the same code on nodejs and browser.\n\n### Browser: `Phonegap`, `Chrome extension` or [node-webkit](https://github.com/rogerwang/node-webkit).\n\nNOTICE: browser must enable **cross-domain** request.\n\nbrowserify to `bundle.js`\n\n```bash\n$ browserify entry.js -o bundle.js\n```\n\nInclude `bundle.js` to your html.\n\n```html\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003ctitle\u003eWeibo Hello world\u003c/title\u003e\n    \u003cscript src=\"bundle.js\"\u003e\u003c/script\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    Hello world.\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n### Use `weibo.oauth` middleware\n\nhandler oauth login middleware, use on connect, express.\n\n```js\n/**\n * oauth middleware for connect\n *\n * example:\n *\n *  connect(\n *    connect.query(),\n *    connect.cookieParser('I\\'m cookie secret.'),\n *    connect.session({ secret: \"oh year a secret\" }),\n *    weibo.oauth()\n *  );\n *\n * @param {Object} [options]\n *   - {String} [homeUrl], use to create login success oauth_callback url with referer header,\n *     default is `'http://' + req.headers.host`;\n *   - {String} [loginPath], login url, default is '/oauth'\n *   - {String} [logoutPath], default is '/oauth/logout'\n *   - {String} [callbackPath], default is login_path + '/callback'\n *   - {String} [blogtypeField], default is 'type',\n *       if you want to connect weibo, login url should be '/oauth?type=weibo'\n *   - {Function(req, res, callback)} [afterLogin], when oauth login success, will call this function.\n *   - {Function(req, res, callback)} [beforeLogout], will call this function before user logout.\n */\n```\n\nExample: A simple web with oauth login.\n\n```js\nvar connect = require('connect');\nvar weibo = require('../');\n\n/**\n * init weibo api settings\n */\n\nweibo.init('weibo', '$appkey', '$secret');\nweibo.init('tqq', '$appkey', '$secret');\nweibo.init('github', '$ClientID', '$ClientSecret');\n\n/**\n * Create a web application.\n */\n\nvar app = connect(\n  connect.query(),\n  connect.cookieParser('oh year a cookie secret'),\n  connect.session({ secret: \"oh year a secret\" }),\n  // using weibo.oauth middleware for use login\n  // will auto save user in req.session.oauthUser\n  weibo.oauth({\n    loginPath: '/login',\n    logoutPath: '/logout',\n    blogtypeField: 'type',\n    afterLogin: function (req, res, callback) {\n      console.log(req.session.oauthUser.screen_name, 'login success');\n      process.nextTick(callback);\n    },\n    beforeLogout: function (req, res, callback) {\n      console.log(req.session.oauthUser.screen_name, 'loging out');\n      process.nextTick(callback);\n    }\n  }),\n  connect.errorHandler({ stack: true, dump: true })\n);\n\napp.use('/', function (req, res, next) {\n  var user = req.session.oauthUser;\n  res.writeHeader(200, { 'Content-Type': 'text/html' });\n  if (!user) {\n    res.end('Login with \u003ca href=\"/login?type=weibo\"\u003eWeibo\u003c/a\u003e | \\\n      \u003ca href=\"/login?type=tqq\"\u003eQQ\u003c/a\u003e | \\\n      \u003ca href=\"/login?type=github\"\u003eGithub\u003c/a\u003e');\n    return;\n  }\n  res.end('Hello, \u003cimg src=\"' + user.profile_image_url + '\" /\u003e\\\n    \u003ca href=\"' + user.t_url +\n    '\" target=\"_blank\"\u003e@' + user.screen_name + '\u003c/a\u003e. ' +\n    '\u003ca href=\"/logout\"\u003eLogout\u003c/a\u003e');\n});\n\napp.listen(8088);\nconsole.log('Server start on http://localhost:8088/');\n```\n\n## Test\n\n```bash\n$ npm install\n$ npm test\n```\n\njscoverage: [79%](http://fengmk2.github.com/coverage/node-weibo.html)\n\n## Authors\n\nBelow is the output from `git-summary`.\n\n```bash\n$ git summary\n\n project  : node-weibo\n repo age : 3 years\n active   : 73 days\n commits  : 173\n files    : 53\n authors  :\n   156  fengmk2                 90.2%\n     7  hpf1908                 4.0%\n     3  chemzqm                 1.7%\n     2  QLeelulu                1.2%\n     1  hbbalfred               0.6%\n     1  im007boy                0.6%\n     1  iwillwen                0.6%\n     1  mk2                     0.6%\n     1  xydudu                  0.6%\n```\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2011-2014 fengmk2 \u0026lt;fengmk2@gmail.com\u0026gt;\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnode-modules%2Fweibo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnode-modules%2Fweibo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnode-modules%2Fweibo/lists"}