2 Star 4 Fork 0

mosandisk / cordova-plugin-weibo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

cordova-plugin-weibosdk

npm npm platform GitHub license

这是一个微博的 Cordova 插件. English
如果有任何问题或是建议,请开 issuss,也欢迎 star 或是 fork。微博SDK部分如有涉及版权问题,版权归新浪微博所有

功能

  • 微博 SSO 登录
  • 微博登出
  • 微博分享
  • 检查微博官方客户端是否安装

安装要求

  • Cordova Version >= 3.5
  • Cordova-Android >= 4.0
  • Cordova-iOS >= 4.0

安装

  1. 命令行运行 cordova plugin add cordova-plugin-weibosdk --variable WEIBO_APP_ID=YOUR_WEIBO_APPID
  2. 在你的config.xml文件中添加 <preference name="REDIRECTURI" value="YOUR_WEIBO_REDIRECTURI" /> 如果你不添加这个选项,那么默认的 redirecturi 是 https://api.weibo.com/oauth2/default.html
  3. 命令行运行 cordova build

注意事项

  1. 这个插件要求 Cordova-Android 的版本 >=4.0,推荐使用 Cordova 5.0 或更高的版本,因为从 Cordova 5.0 开始 Cordova-Android 4.0 是默认使用的 Android 版本
  2. 请在 Cordova 的 deviceready 事件触发以后再调用本插件!!!!!
  3. 在低于5.1.1的 Cordova 版本中存在一个 Bug,如果你有多个插件要修改 iOS 工程中的 “*-Info.plist” CFBundleURLTypes, 只有第一个安装的插件才会生效.所以安装完插件请务必在你的 Xcode 工程里面检查一下 URLTypes。 关于这个 bug 的详情你可以在 这里找到 建议安装使用5.1.1及以上的 Cordova 版本

使用方法

微博SSO登录

WeiboSDK.ssoLogin(function (args) {
   alert('access token is ' + args.access_token);
   alert('userId is ' + args.userId);
   alert('expires_time is ' + new Date(parseInt(args.expires_time)) + ' TimeStamp is ' + args.expires_time);
}, function (failReason) {
   alert(failReason);
});

微博登出

WeiboSDK.logout(function () {
   alert('logout success');
}, function (failReason) {
   alert(failReason);
});

微博分享

var args = {};
args.url = 'https://cordova.apache.org/';
args.title = 'Apache Cordova';
args.description = 'This is a Cordova Plugin';
args.image = 'https://cordova.apache.org/static/img/pluggy.png';
WeiboSDK.shareToWeibo(function () {
   alert('share success');
}, function (failReason) {
   alert(failReason);
}, args);

检查微博客户端是否安装

WeiboSDK.checkClientInstalled(function () {
   alert('client is installed');
}, function () {
   alert('client is not installed');
});

获取用户信息

var url = 'https://api.weibo.com/2/users/show.json?uid=' + usrid + '&&access_token=' + token;
http.get(url)

测试Demo

在安装完这个插件以后,把 Cordova 工程中的代码替换为 example_www 中的代码,在 build 以后可以进行各个功能测试,以下为运行效果图:

example

关于微博SDK

你可以在这里,找到最新的微博 SDK,如果发现 bug 请开 issus,同时也欢迎 star 和 fork

贡献代码

欢迎提交 PR,贡献你的代码,如果有新功能,请提供 Demo。

开源证书

cordova-plugin-weibosdk 遵照了 MIT 证书. 详情可以查看 证书 文件

The MIT License (MIT) Copyright (c) 2015 Van Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

这是一个微博的 Cordova 插件 展开 收起
JavaScript
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
JavaScript
1
https://gitee.com/modisk/cordova-plugin-weibo.git
git@gitee.com:modisk/cordova-plugin-weibo.git
modisk
cordova-plugin-weibo
cordova-plugin-weibo
master

搜索帮助