Coder Social home page Coder Social logo

alpaca-coco / cordova-plugin-weibo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from belinchung/cordova-plugin-weibo

0.0 2.0 0.0 8.94 MB

Cordova (PhoneGap) Plugin to connect to the native Weibo SDK

License: MIT License

CSS 4.05% HTML 2.80% JavaScript 4.47% Java 10.86% Objective-C 77.82%

cordova-plugin-weibo's Introduction

cordova-plugin-weibo

Cordova (PhoneGap) Plugin to connect to the native Weibo SDK

Installation

cordova plugins add cordova-plugin-weibo

iOS

1. 设置工程回调的 URL Types

info -> URL Types 添加:  
identifier: com.weibo  
URL schemes: wbYouAppkey (wb239283940)

2. 重写 AppDelegate.m

AppDelegate.m 在 Xcode 项目的 Classes 文件夹中

  • 在头部引入相关文件
#import "WeiboSDK.h"
#import "weibo.h"
  • 重写 AppDelegatehandleOpenURLopenURL 方法
    以前这两个方法有内容就直接添加如下方法中代码
- (BOOL)application:(UIApplication*)application openURL:(NSURL*)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation
{
 	weibo *weiboPlugin = [self.viewController.pluginObjects objectForKey:@"weibo"];
    [WeiboSDK handleOpenURL:url delegate:weiboPlugin];

    return YES;
}

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
    [WeiboSDK handleOpenURL:url delegate:self ];
    
    return YES;
}

Android

Android 暂时无需修改任何配置或代码

JavaScript API

初始化 appKey 和 redirectURI

window.weibo.init(appKey, redirectURI, onSuccess, onFail)

微博 SSO 授权登录(未安装将使用 Web 授权)

window.weibo.login(onSuccess, onFail)

手机验证码注册/登录

window.weibo.vcodeLogin(args,onSuccess, onFail)

判断是否安装微博客户端

window.weibo.isInstalled(onSuccess, onFail)

分享图文信息到微博

window.weibo.share(args,onSuccess, onFail)

Quick Example

window.weibo.init('3281812343','http://www.example.com/callback.html');

$$('#wbLoginBtn').on('click',function(){
	window.weibo.login(function (res) {
	    console.log(res);
	});
})

$$('#wbShareBtn').on('click',function(){
    window.weibo.share({
        type: 'image',
        data: 'http://ww3.sinaimg.cn/large/77565b1bjw1eqd6s01q6ej20c80c80t4.jpg',
        text: 'test my plugin'
    },function(res){
        console.log(res);
    });
})

更详细的使用教程可 checkout example 目录代码替换 cordova 项目的 www 目录即可

License

Copyright (c) 2015 Belin Chung. MIT Licensed, see LICENSE for details.

cordova-plugin-weibo's People

Contributors

belinchung avatar cxcxcxcx avatar

Watchers

James Cloos avatar Zhu Qi Cong avatar

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.