A Cordova wrapper around the Tencent QQ SDK for Android and iOS. Provides access to QQ ssoLogin, QQ Sharing, QQ Zone Sharing etc.. 简体中文.
1.cordova plugin add cordova-plugin-qqsdk --variable QQ_APP_ID=YOUR_QQ_APPID
Platform | iOS | iOS | iOS | Android | Android | Android |
---|---|---|---|---|---|---|
ShareScene | QQZone | QQ Favorite | QQZone | QQ Favorite | ||
Text | √ | √ | √ | ✕ | √ | √ |
Image | √ | √ | √ | √ | √ | √ |
News | √ | √ | √ | √ | √ | √ |
Audio | √ | √ | √ | √ | √ | √ |
When you use qq login,you may get an error code.If you get one, find detail error msg from here please.
This plugin support three Image types:
var args = {};
args.client = QQSDK.ClientType.QQ;//QQSDK.ClientType.QQ,QQSDK.ClientType.TIM;
QQSDK.checkClientInstalled(function () {
alert('client is installed');
}, function () {
// if installed QQ Client version is not supported sso,also will get this error
alert('client is not installed');
}, args);
var args = {};
args.client = QQSDK.ClientType.QQ;//QQSDK.ClientType.QQ,QQSDK.ClientType.TIM;
QQSDK.ssoLogin(function (result) {
alert('token is ' + result.access_token);
alert('userid is ' + result.userid);
alert('expires_time is ' + new Date(parseInt(result.expires_time)) + ' TimeStamp is ' + result.expires_time);
}, function (failReason) {
alert(failReason);
}, args);
QQSDK.logout(function () {
alert('logout success');
}, function (failReason) {
alert(failReason);
});
var args = {};
args.client = QQSDK.ClientType.QQ;//QQSDK.ClientType.QQ,QQSDK.ClientType.TIM;
args.scene = QQSDK.Scene.QQ;//QQSDK.Scene.QQZone,QQSDK.Scene.Favorite
args.text = '这个是 Cordova QQ 分享文字';
QQSDK.shareText(function () {
alert('shareText success');
}, function (failReason) {
alert(failReason);
}, args);
var args = {};
args.client = QQSDK.ClientType.QQ;//QQSDK.ClientType.QQ,QQSDK.ClientType.TIM;
args.scene = QQSDK.Scene.QQ;//QQSDK.Scene.QQZone,QQSDK.Scene.Favorite
args.title = '这个是 Cordova QQ 图片分享的标题';
args.description = '这个是 Cordova QQ 图片分享的描述';
args.image = 'https://cordova.apache.org/static/img/cordova_bot.png';
QQSDK.shareImage(function () {
alert('shareImage success');
}, function (failReason) {
alert(failReason);
}, args);
var args = {};
args.client = QQSDK.ClientType.QQ;//QQSDK.ClientType.QQ,QQSDK.ClientType.TIM;
args.scene = QQSDK.Scene.QQ;//QQSDK.Scene.QQZone,QQSDK.Scene.Favorite
args.url = 'https://cordova.apache.org/';
args.title = '这个是 Cordova QQ 新闻分享的标题';
args.description = '这个是 Cordova QQ 新闻分享的描述';
args.image = 'https://cordova.apache.org/static/img/cordova_bot.png';
QQSDK.shareNews(function () {
alert('shareNews success');
}, function (failReason) {
alert(failReason);
}, args);
var args = {};
args.client = QQSDK.ClientType.QQ;//QQSDK.ClientType.QQ,QQSDK.ClientType.TIM;
args.scene = QQSDK.Scene.QQ;//QQSDK.Scene.QQZone,QQSDK.Scene.Favorite
args.url = 'https://y.qq.com/portal/song/001OyHbk2MSIi4.html';
args.title = '十年';
args.description = '陈奕迅';
args.image = 'https://y.gtimg.cn/music/photo_new/T001R300x300M000003Nz2So3XXYek.jpg';
args.flashUrl = 'http://stream20.qqmusic.qq.com/30577158.mp3';
QQSDK.shareAudio(function () {
alert('shareAudio success');
}, function (failReason) {
alert(failReason);
}, args);
var url = 'https://graph.qq.com/user/get_user_info?access_token=' + accessToken + '&oauth_consumer_key=' + QQ_APP_ID + '&openid=' + userId;
http.get(url)
This plugin use 3.2.1 version sdk for Android,3.2.3 version sdk for iOS. You can download lastest version sdk here
Feel free to contribute
cordova-plugin-qqsdk is released under the MIT license. See LICENSE file for more information.