Giter Club home page Giter Club logo

cordova_weibo's Introduction

Cordova_Weibo_Plugin

version platform GitHub license Contact

This is a Cordova Plugin for WeiboSDK. 简体中文
I also write a cordova plugin for qq sdk here.

Feature

  • Weibo SSO Login
  • Weibo Logout
  • Weibo WebPage Share
  • Check Weibo Client is Installed

Requirements

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

Installation

  1. cordova plugin add https://github.com/iVanPan/cordova_weibo.git --variable WEIBO_APP_ID=YOUR_WEIBO_APPID or cordova plugin add cordova-plugin-weibosdk --variable WEIBO_APP_ID=YOUR_WEIBO_APPID
  2. Add <preference name="REDIRECTURI" value="YOUR_WEIBO_REDIRECTURI" /> in your config.xml If you don't add this preference the defualt redirecturi is https://api.weibo.com/oauth2/default.html
  3. cordova build

##Notes

  1. This plugin is required cordova-android version >=4.0,so using cordova 5.0.0 or higher is recommended
  2. This plugin should be used after the deviceready event has been fired!!!
  3. ~~If cordova version <5.1.1,when two cordova plugins are modifying “*-Info.plist” CFBundleURLTypes, only the first added plugin is getting the changes applied.so after installing plugin,please check the URLTypes in your Xcode project.You can find this issue here.~~Update:This Bug is fixed in last cordova version(5.1.1)

##ISSUES 1.if you are sharing webpage without weibo app client ,the webpage sharing becomes text sharing.

Usage

Weibo SSO Login

YCWeibo.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){
         console.log(failReason);
});

Weibo Logout

YCWeibo.logout(function(){
	console.log('logout success');
},function(failReason){
	console.log(failReason);
});

Weibo Webpage Share

var args = {};
args.url = "http://www.baidu.com";
args.title = "Baidu";
args.description = "This is Baidu";
args.imageUrl = "https://www.baidu.com/img/bdlogo.png";//if you don't have imageUrl,for android http://www.sinaimg.cn/blog/developer/wiki/LOGO_64x64.png will be the defualt one
args.defaultText = "";
YCWeibo.shareToWeibo(function () {
    alert("share success");
 }, function (failReason) {
    alert(failReason);
 }, args);

CheckClientInstalled

YCWeibo.checkClientInstalled(function(){
	console.log('client is installed');
},function(){
	console.log('client is not installed');
});

##Example

  1. install this plugin
  2. backup www folder in your cordova project
  3. replace www by example_www
  4. cordova build & test

##About WeiboSdk you can downlaod last weibosdk here .if you find any problem about weibosdk, open an isssus please.

##About Get User Info after weibo sso Login,you can get access_token and userid,using get method to get user info directly with url https://api.weibo.com/2/users/show.json?uid=xxxx&access_token=xxxx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.