Giter VIP home page Giter VIP logo

sns-sdk's Introduction

sns-sdk

获取第三方授权信息,以及分享的配置

  1. 支持微信、QQ 以及微博的授权,并返回用户信息
  2. 支持微信分享配置

依赖

  1. 只有在 *.ele.me 下才可以使用
  2. 平台的 sdk eg: weixin.js
  3. uparams

引入方式

<!-- 判断微信浏览器,并引入微信的 SDK -->
<script>
if (/MicroMessenger/i.test(navigator.userAgent))
  document.write('<script src="//res.wx.qq.com/open/js/jweixin-1.0.0.js"><\/script>')
</script>
<!-- 引入依赖 UParams -->
<script src="http://github.elemecdn.com/YanagiEiichi/uparams/1.3.0/uparams.min.js"></script>
<!-- 引入 sns-sdk,注意版本 -->
<script src="//github.elemecdn.com/eleme/sns-sdk/{x.y.z}/sns-sdk.js"></script>

使用

调用平台分享功能

sns.share({
  title: '分享标题',
  desc: '分享描述',
  // 注意!imgUrl 和 link 必须是以 http 或 https 开头的绝对 URL
  imgUrl: '分享图标',
  link: '分享链接'
})

获取用户信息(可能会跳到授权页再链接回来,导致页面重新加载
user 数据结构

sns.getUserInfo(user => {
  /**
   # 此处 user 的值为
   {
     openid: "唯一标识符",
     name: "用户昵称",
     avatar: "头像链接",
     // ...
   }
  **/
})

微信授权逻辑

sns-sdk's People

Contributors

banrikun avatar coffeexy avatar liuxiangyu avatar yanagieiichi avatar youngerheart avatar

Watchers

 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.