
Security News
The Code You Didn't Write Is Still Yours to Defend
AI agents are pulling packages into environments no scanner is watching, creating exposure before security teams can see it.
安装
npm install iweibo
var iweibo = require('iweibo');
var Weibo = iweibo.Weibo;
iweibo.set({
appkey: 'xxx',
appsecret: 'xxxxxxxxxx'
})
支持的配置:
var CONFIG = {
appkey: '',
appsecret: '',
oauth_host: 'https://api.weibo.com/oauth2/authorize',
access_url: 'https://api.weibo.com/oauth2/access_token',
api_url: 'https://api.weibo.com/2/'
}
iweibo.setAPI('statuses/update', {
method: 'post',
params: {
status: 'hello, world',
visible: 0
}
});
配置下微博接口(由于太多,并且不时更新,所以我就没全配置),配置下自己使用的接口,方法参考下件,基本如下:
'接口名称': {
method: 'get', //请求方法,post或者get(get可省略),参考api文档
params: { //默认参数,不用填写appkey和access_token,程序会自动补上
}
}
可以讲接口统一写到一个json或者js文件中,然后使用 require 引入,直接给 setAPI 传入
参考 examples/app.js 文件(需要先在本目录执行 npm install 安装依赖模块)
修改host,添加下面内容:
127.0.0.1 testapp.cn
进入 open.weibo.com 设置应用回调地址到 http://testapp.cn/callbak
weibo.getAuthorizeURL(backURL);
weibo.getAccessToken('code', {
code: code,
redirect_uri: backURL
}).done(function(err, data) {
var realpath = templateDir + 'callback.html';
html = fs.readFileSync(realpath);
data = JSON.parse(data);
data.refresh_token = data.refresh_token || '';
req.session.refresh_token = data.refresh_token;
req.session.access_token = data.access_token;
req.session.uid = data.uid;
html = bdTemplate(html, data);
res.end(html);
}).fail(function(err, data) {
var html;
if (err) {
html = fs.readFileSync(templateDir + 'error.html');
}
res.end(html);
});
//所有API都支持promise接口
weibo.api('users/show', urlObj).done(function(err, result) {
console.log(result);
res.end(JSON.stringify(result));
});
examplesconfig.json,回调地址需要在open.weibo.com配置好,然后修改自己的host,将回调地址指到127.0.0.1npm installconfig.json配置的网站FAQs
新浪微博 node sdk 客户端
The npm package iweibo receives a total of 5 weekly downloads. As such, iweibo popularity was classified as not popular.
We found that iweibo demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
AI agents are pulling packages into environments no scanner is watching, creating exposure before security teams can see it.

Security News
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.