All Projects → jiangxianli → wechatShare-JS

jiangxianli / wechatShare-JS

Licence: other
微信JS分享到朋友圈、微博、QQ好友等

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to wechatShare-JS

Wechat Api
🗯 wechat-api by java7.
Stars: ✭ 1,813 (+3677.08%)
Mutual labels:  wechat-sdk
Wechat
WeChat SDK for Go (微信SDK:简单、易用)
Stars: ✭ 3,144 (+6450%)
Mutual labels:  wechat-sdk
vue-authorization-login
vue+express实现微信授权登录demo
Stars: ✭ 21 (-56.25%)
Mutual labels:  wechat-sdk
Abp.wechat
Abp 微信 SDK 模块,包含对微信小程序、公众号、企业微信、开放平台、第三方平台等相关接口封装。
Stars: ✭ 168 (+250%)
Mutual labels:  wechat-sdk
Yii2 Easy Wechat
WeChat SDK for yii2 , based on overtrue/wechat.
Stars: ✭ 188 (+291.67%)
Mutual labels:  wechat-sdk
wxEditor
微信编辑器,微信排版,微信公众号编辑器, 微信素材,前后端已搭建完整,原UEditor(百度编辑器,PHP1.4.3版) 二次开发 (微信编辑器,微信公众号,图文发布在线编辑器) 。
Stars: ✭ 86 (+79.17%)
Mutual labels:  wechat-sdk
Gochat
🔥 微信 Go SDK 🚀🚀🚀
Stars: ✭ 141 (+193.75%)
Mutual labels:  wechat-sdk
wechat
微信小程序 微信公众号 微信支付 golang
Stars: ✭ 39 (-18.75%)
Mutual labels:  wechat-sdk
Wechat
轻量的微信公众号组件(A Lightweight Wechat Component)
Stars: ✭ 195 (+306.25%)
Mutual labels:  wechat-sdk
wechat-sdk
微信公众平台/开放平台(第三方平台) JAVA SDK
Stars: ✭ 36 (-25%)
Mutual labels:  wechat-sdk
Weixin Java Cp Demo
基于Spring Boot 和 WxJava 实现的微信企业号/企业微信 后端Demo
Stars: ✭ 175 (+264.58%)
Mutual labels:  wechat-sdk
Go Workwx
a sensible Work Weixin(企业微信, Wechat Work) SDK for Go
Stars: ✭ 181 (+277.08%)
Mutual labels:  wechat-sdk
go-wechat
💥weixin、wechat、微信公众平台、企业微信 golang/go sdk
Stars: ✭ 18 (-62.5%)
Mutual labels:  wechat-sdk
Caswechat
caswechat 微信全接口SDK封装
Stars: ✭ 155 (+222.92%)
Mutual labels:  wechat-sdk
weapp wechat miniapp sdk
一个封装了微信小程序服务端接口的SDK
Stars: ✭ 102 (+112.5%)
Mutual labels:  wechat-sdk
Yii2 Wx
这可能是yii2中最好用的微信SDK🔥🔥🔥
Stars: ✭ 148 (+208.33%)
Mutual labels:  wechat-sdk
Laravel Wechat
微信 SDK for Laravel, 基于 overtrue/wechat
Stars: ✭ 2,690 (+5504.17%)
Mutual labels:  wechat-sdk
example
【例子】微信开发SDK(Wechat SDK For Golang)
Stars: ✭ 27 (-43.75%)
Mutual labels:  wechat-sdk
union
union login for wechat,weibo,qq,alipay with go
Stars: ✭ 23 (-52.08%)
Mutual labels:  wechat-share
wechat-starter-boot-spring
简化微信对接流程,避免重复性工作和填坑
Stars: ✭ 22 (-54.17%)
Mutual labels:  wechat-sdk

wechatShare-JS

微信JSSDK分享到朋友圈、微博、QQ好友。 ##升级 为了更灵活的使用,请使用V0.1.1版本,原V0.1.0请点击这里查看。

JS-SDK使用权限签名算法步骤

  1. 使用appId、appSecret获取AccessToken:

http请求方式: GET https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET 返回参数: {"access_token":"ACCESS_TOKEN","expires_in":7200} 文档地址: https://mp.weixin.qq.com/wiki/15/54ce45d8d30b6bf6758f68d2e95bc627.html

  1. 使用1)中AccessToken获取jsapi_ticket:

http请求方式: GET https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=ACCESS_TOKEN&type=jsapi 返回参数: {"errcode":0,"errmsg":"ok","ticket":"bxLdikRXVbTPdHSM05e5u5sUoXNKd8-41ZO3MhKoyN5OfkWITDGgnr2fwJ0m9E8NYzWKVZvdVtaUgWvsdshFKA","expires_in":7200}

  1. 使用2)中jsapi_ticket生成signature:

签名生成规则如下:参与签名的字段包括noncestr(随机字符串), 有效的jsapi_ticket, timestamp(时间戳), url(当前网页的URL,不包含#及其后面部分) 。对所有待签名参数按照字段名的ASCII 码从小到大排序(字典序)后,使用URL键值对的格式(即key1=value1&key2=value2…)拼接成字符串string1。这里需要注意的是所有参数名均为小写字符。对string1作sha1加密,字段名和字段值都采用原始值,不进行URL 转义。

准备工作

1.引入jquery、sha1加密、weixin、share插件这4个JS文件

<script src="js/jquery-1.11.1.js"></script>
<script src="js/jquery.sha1.js"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script src="js/jquery.wechat.share.js"></script>

使用

在页面中添加script脚本,建议通过后台产生签名的方式写入到前端页面,这样更安全(推荐使用优先级如下)

<script>
  $(function(){

    //第一种方式:使用appId,signature
    var shareData = {
        appId: 'wx2c82806de7e9cc08',
		signature: '0f9de62fce790f9a083d5c99e95740ceb90c27ed',
        title: '标题',
        desc: '简介',
        link: '分享的链接。一般可以用location.href',
        imgUrl: '分享的图片链接地址(图片一定要是网络图片地址哦,这样才能保证别人看到的图片是正常显示的)'
    };
    $.wechatShare(shareData);

    //第二种方式:使用appId,accessToken
    shareData = {
        appId: 'wx2c82806de7e9cc08',
        accessToken: '37vCDdOYC1nbgDZD__-Qs_poFtAmYkumU7xxxxx6Lj66_xJ8bj8LDFY3SwvBe1QHQ4HT_fzMjSAZeeQ-BhvVvUh8K00j4CWFOVa-N4QQTcAFAVVY',
        title: '标题',
        desc: '简介',
        link: '分享的链接。一般可以用location.href',
        imgUrl: '分享的图片链接地址(图片一定要是网络图片地址哦,这样才能保证别人看到的图片是正常显示的)'
    };
    $.wechatShare(shareData);

    //第三种方式:使用appId,appSecret
    shareData = {
        appId: 'wx2c82806de7e9cc08',
        appSecret: 'cc4c224b50fkjlksdafkldfsakljsdfk',
        title: '标题',
        desc: '简介',
        link: '分享的链接。一般可以用location.href',
        imgUrl: '分享的图片链接地址(图片一定要是网络图片地址哦,这样才能保证别人看到的图片是正常显示的)'
    };
    $.wechatShare(shareData);
  })
</script>

完毕

是不是感觉非常简单~~

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].