npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

offlyer-react-native-weibo

v1.0.2

Published

新浪微博登录模块

Downloads

2

Readme

react-native-weibo-login

React Native App接入微博登陆,不需要分享,在github找到了react-native-weibo,可惜该库已经一年没有更新,使用的不是最新的微博SDK( android SDK版本:4.1,ios SDK版本3.2.1 ),不能很好的兼容最新的RN( 0.55.4 )版本,所以自己动手写了这个库,实现了微博登陆,没实现分享功能。

Getting started

$ npm install react-native-weibo-login --save

or

yarn add react-native-weibo-login

Mostly automatic installation

$ react-native link react-native-weibo-login

Manual installation

iOS

  1. Add node_modules/react-native-weibo-login/ios/WeiboSDK.bundle in you project, or else it will be crash.

  2. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name], Go to node_modulesreact-native-weibo-login and add RCTWeiBo.xcodeproj.

  3. In XCode, in the project navigator, select your project.

    Add

    • libRCTWeiBo.a
    • QuartzCore.framework
    • ImageIO.framework
    • SystemConfiguration.framework
    • Security.framework
    • CoreTelephony.framework
    • CoreText.framework
    • UIKit.framework
    • Foundation.framework
    • CoreGraphics.framework
    • Photos.framework
    • libz.tbd
    • libsqlite3.tbd

    to your project's Build PhasesLink Binary With Libraries.

  4. In the project navigator, in TargetsinfoURL types. Add new URL type, Identifier value is com.weibo, URL Schemes value is wb + you weibo appKey, such as: wb2317411734.

  5. Right click Info.plist open as source code, insert the following lines:

    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>sinaweibohd</string>
        <string>weibosdk</string>
        <string>sinaweibo</string>
        <string>weibosdk2.5</string>
    </array>
  6. Copy the following in AppDelegate.m:

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
  return [RCTLinkingManager application:application openURL:url
                            sourceApplication:sourceApplication annotation:annotation];
}

Android

  1. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add import com.gratong.WeiBoPackage; to the imports at the top of the file.
  • Add new WeiBoPackage() to the list returned by the getPackages() method.
  1. Append the following lines to android/settings.gradle:
    include ':react-native-weibo-login'
    project(':react-native-weibo-login').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-weibo-login/android')
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':react-native-weibo-login')
  3. Insert the following lines inside the allprojects block in android/build.gradle:
      maven { url "https://dl.bintray.com/thelasterstar/maven/" }
    such as:
    allprojects {
       repositories {
          mavenLocal()
          jcenter()
          maven { url "https://dl.bintray.com/thelasterstar/maven/" }
        }
    }

Config

  • appKey: 你在微博开放平台上申请的应用ID
  • scope:OAuth2.0 授权机制中 authorize 接口的一个参数。通过 Scope,平台将开放更多的微博核心功能给开发者,同时也加强用户隐私保护,提升了用户体验,用户在新 OAuth2.0 授权页中有权利选择赋予应用的功能。目前 Scope 支持传入多个 Scope 权限,用逗号分隔。赋值为all代表请求所有scope权限。关于 Scope 概念及注意事项,请查看:http://open.weibo.com/wiki/Scope
  • redirectURI:默认 https://api.weibo.com/oauth2/default.html,必须和sina微博开放平台中应用高级设置中的redirectURI设置的一致,不然会登录失败

Usage

import * as WeiBo from 'react-native-weibo-login';

let config = {
    appKey:"2317411734",
    scope: 'all',       
    redirectURI: 'https://api.weibo.com/oauth2/default.html',
}

WeiBo.login(config)
    .then(res=>{  
        console.log('login success:',res)
        //登陆成功后打印出的数据如下:
        // { 
        //     refreshToken: '2.00Gc2PbDcecpWC127d0bc690FE7TzD',
        //     type: 'WBAuthorizeResponse',
        //     expirationDate: 1686362993740.243,
        //     userID: '3298780934',
        //     errCode: 0,
        //     accessToken: '2.00Gc2PbDcecpWCa981899f410o5hEX' 
        // }
    }).catch(err=>{ 
        console.log('login fail:',err)
    })