GithubHelp home page GithubHelp logo

lanrion / weixin_authorize Goto Github PK

View Code? Open in Web Editor NEW
323.0 19.0 116.0 200 KB

微信 Ruby 高级API weixin_authorize http://github.com/lanrion/weixin_authorize .

License: MIT License

Ruby 100.00%
wexin-ruby-api

weixin_authorize's Introduction

WeixinAuthorize

Gem Version Build Status Code Climate Coverage Status

Support using Redis to store access_token

Wiki

Getting-Started

JS SDK

支持自助实现API

详情见:https://github.com/lanrion/weixin_authorize/wiki/diy-your-api

已经完成API

  • 客服消息
  • 模板消息
  • 用户分组管理
  • 用户信息管理
  • Oauth 2授权
  • 二维码生成
  • 自定义菜单
  • 群发消息
  • 多媒体管理
  • JS SDK(ticket支持缓存)
  • 更多请查看测试例子

V2.0开发中:

https://github.com/lanrion/weixin_authorize/milestones/v2.0-dev

  1. 重构API实现,调用方式
  2. 对token,ticket的管理,提供第三方开发灵活者自助化
  3. 尝试RestClient的弃用,选择更高效的HTTP client包
  4. 支持更多的异常处理机制

注意:查看Wiki或者源代码时,请切换对应的版本来查看。Master处于不断更新完善分支。

How to test

Go to #2, apply a weixin sandbox test account and follow this account

https://github.com/lanrion/weixin_authorize/blob/master/spec/spec_helper.rb

change your infos:

ENV["APPID"]="wxe371e0960de5426a"
ENV["APPSECRET"]="572b93d3d20aea242692a804243a141b"
ENV["OPENID"]="oEEoyuEasxionjR5HygmEOQGwRcw"

then run rspec .

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

捐赠支持

如果你觉得我的gem对你有帮助,欢迎打赏支持,:smile:

weixin_authorize's People

Contributors

hysios avatar lang1pal avatar lanrion avatar peterfei avatar smoothdvd avatar wikimo avatar ysllyfe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

weixin_authorize's Issues

在JRuby环境下无法正常安装

weixin_authorize依赖于yajl-ruby,而yajl-ruby是基于C的扩展,在JRuby环境中不能安装。请问可否使用yajl-ruby的替代gem从而增加对JRuby的支持?

redis-namespace版本问题

wiki里面说gem "redis-namespace", "~> 1.4.1"
出现错误:

weixin_authorize (>= 0) ruby depends on
      redis (>= 3.1.0) ruby

    redis-namespace (~> 1.4.1) ruby depends on
      redis (~> 3.0.4) ruby

我有什么地方想错了?

调用followers,报错

调用is_valid?,正常
调用followers,报错
{"errcode"=>40001, "errmsg"=>"invalid credential"}

微信卡券接口参数 Map

微信卡券由于参数过多,构建Json时,需要传入很多参数。
而官方提供的接口参数文档结构层次不明晰,因此特别整理了一个 API Map 方便各位做开发
微信卡券API基本结构为(详见):

  • card_type
  • (团购券) deal_detail
  • (代金券) least_cost
  • (代金券) reduce_cost
  • (折扣券) discount
  • (礼品券) gift
  • (优惠券) default_detail
  • (会员卡) activate_url
  • (会员卡) prerogative
  • (会员卡) supply_bonus
  • (会员卡) bonus_url
  • (会员卡) bonus_cleared
  • (会员卡) bonus_rules
  • (会员卡) supply_balance
  • (会员卡) balance_url
  • (会员卡) balance_rules
  • (会员卡) custom_field1
  • (会员卡) custom_field2
  • (会员卡) custom_field3
  • (会员卡) custom_cell1
  • base_info
    • logo_url
    • code_type
    • brand_name
    • title
    • sub_title
    • color
    • notice
    • description
    • sku
    • date_info
    • use_custom_code
    • bind_openid
    • service_phone
    • location_id_list
    • source
    • custom_url_name
    • custom_url
    • custom_url_sub_title
    • promotion_url_name
    • promotion_url
    • promotion_url_sub_title
    • get_limit
    • can_share
    • can_give_friend

NoMethodError (undefined method `count' for ……

def generate_article(title, desc, pic_url, link_url)
item = Article.new
item.Title = title
item.Description = desc
item.PicUrl = pic_url
item.Url = link_url
item
end

# articles = [generate_article]
def reply_news_message(from=nil, to=nil, articles)
  message = NewsReplyMessage.new
  message.FromUserName = from || @weixin_message.ToUserName
  message.ToUserName   = to   || @weixin_message.FromUserName
  message.Articles     = articles
  message.ArticleCount = articles.count   ???
  message.to_xml
end

问题:在接口超出限制的情况下,调用直接报错。

user_info_handler = weixin_client.user(ENV["OPENID"])
puts user_info_handler.en_msg # 打印出英文提示信息
puts user_info_handler.cn_msg

Completed 500 Internal Server Error in 198ms

WeixinAuthorize::ValidAccessTokenException (45009: api freq out of limit(接口调用超过限制).):

生成字符串参数永久二维码问题

生成字符串参数的永久二维码,参数如果传入options[:scene_str], 则action_name不应是QR_LIMIT_SCENE,而是qrcode_infos = {action_name: "QR_LIMIT_STR_SCENE"},现在好像没这个分支,如果传字符串,扫描时不能返回

支持模板消息

请问,现在的提供的API里有发送模板消息的功能吗?

图文消息没有content选项?

在官文页面里有个content项,我看在这里只有链接到外面页面的。我们能不能实现gem直接群发图文消息,像在微信公众号后台那种的,内容显示在它的服务器(mp.weixin.qq.com)的那种?
我在微信提供的debug页面里发出去的,只能显示title,图片,和内容页都跳不过去。

{
    "touser": "owwwHUst1nmXeQp7qh_Ajo6TMvjWI",
    "msgtype": "news",
    "news": {
        "articles": [
            {
                "thumb_media_id": "OMU7YKWr5ZcLyuowwCRPaWkHcQJNKM38i_fFHSLDcCYQOh99bwg_pMzGXHAQutVN",
                "author": "xxx",
                "description": "Is Really A Happy Day",
                "title": "Happy Day",
                "content_source_url": "www.qq.com",
                "content": "content",
                "digest": "digest",
                "show_cover_pic": "1"
            }
        ]
    }
}

http://mp.weixin.qq.com/wiki/15/5380a4e6f02f2ffdc7981a8ed7a40753.html

Redis after Forking disconnected 的问题

似乎在 access_token 过期后会出现
Tried to use a connection from a child process without reconnecting. You need to reconnect to Redis after forking.
的问题

请问是插件逻辑不完善还是我配置有问题?

undefined method `get_jssign_package' for #<WeixinAuthorize::Client:0x007f6400dd95f8>

我跟着 JS SDK Guide 引入 JS 时出现

undefined method `get_jssign_package' for #<WeixinAuthorize::Client:0x007f6400dd95f8>

可以看到 WeixinAuthorize::Client 已经被实例化
但是却找不到方法 get_jssign_package
而我在 Rails 控制台中调试却是正常的:

@client = WeixinAuthorize::Client.new('MYAPPID', 'MYSECRET')
 => #<WeixinAuthorize::Client:0x00000006d644e8 @app_id="MYAPPID", @app_secret="MYSECRET", @expired_at=1439809528, @jsticket_expired_at=1439809528, @redis_key="69BADA70FEBAD734AB6F94177715F2E8", @jsticket_redis_key="C8A27434B70A6BC35E87EC5EF158A4F7"> 
sign_package = @client.get_jssign_package('http://url.cn')
 => {"appId"=>"wxcd6acbc5a9500d7b", "nonceStr"=>"f76af164ddda752fa230c6bd28ab9624", "timestamp"=>1439809546, "url"=>"http://url.cn", "signature"=>"0762c051babbb8995bd5cd13f92b2efee6db30cf", "rawString"=>"jsapi_ticket=kgt8ON7yVITDhtdwci0qeRz5E-G28wsVRiGU0_83PK9d0ylzs2DYONzyUxbKh32gdwTWX6GXGIskrQnxKETLvQ&noncestr=f76af164ddda752fa230c6bd28ab9624&timestamp=1439809546&url=http://url.cn"} 

Client 初始化过程:

class ApplicationController < ActionController::Base
before_action :init_weixin
  def init_weixin
    $weixin_client ||= WeixinAuthorize::Client.new('MYAPPID', 'MYSECRET')
  end
end

我在交流群里问了几个朋友都不知道怎么回事…
不知道我代码哪儿出了问题,能给思路吗?

上传接口调用反馈

1.接口说明不完善,比如比如file_url(这是只本地,如果是url了?)
2.调用后返回,responce.result 为 {} (调用成功后没有返回任何东西)

restclient Request Timeout

自从昨晚凌晨起,restclient Request Timeout的报错信息不停。是不是你那里做了什么改动?

高级群发接口

http://mp.weixin.qq.com/wiki/index.php?title=高级群发接口

在公众平台网站上,为订阅号提供了每天一条的群发权限,为服务号提供每月(自然月)4条的群发权限。而对于某些具备开发能力的公众号运营者,可以通过高级群发接口,实现更灵活的群发能力。

请注意:

1、该接口暂时仅提供给已微信认证的服务号
2、虽然开发者使用高级群发接口的每日调用限制为100次,但是用户每月只能接收4条,请小心测试
3、无论在公众平台网站上,还是使用接口群发,用户每月只能接收4条群发消息,多于4条的群发将对该用户发送失败。

create_menu 的时候出错 sslv3 alert handshake failure

OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server hello A: sslv3 alert handshake failure
    from /root/.rbenv/versions/2.1.2/lib/ruby/2.1.0/net/http.rb:920:in `connect'
    from /root/.rbenv/versions/2.1.2/lib/ruby/2.1.0/net/http.rb:920:in `block in connect'
    from /root/.rbenv/versions/2.1.2/lib/ruby/2.1.0/timeout.rb:76:in `timeout'
    from /root/.rbenv/versions/2.1.2/lib/ruby/2.1.0/net/http.rb:920:in `connect'
    from /root/.rbenv/versions/2.1.2/lib/ruby/2.1.0/net/http.rb:863:in `do_start'
    from /root/.rbenv/versions/2.1.2/lib/ruby/2.1.0/net/http.rb:852:in `start'
    from /var/www/dvoy/shared/bundle/ruby/2.1.0/gems/rest_client-1.7.3/lib/restclient/request.rb:182:in `transmit'
    from /var/www/dvoy/shared/bundle/ruby/2.1.0/gems/rest_client-1.7.3/lib/restclient/request.rb:68:in `execute'
    from /var/www/dvoy/shared/bundle/ruby/2.1.0/gems/rest_client-1.7.3/lib/restclient/request.rb:35:in `execute'
    from /var/www/dvoy/shared/bundle/ruby/2.1.0/gems/rest_client-1.7.3/lib/restclient.rb:69:in `get'
    from /var/www/dvoy/shared/bundle/ruby/2.1.0/gems/weixin_authorize-1.0.1/lib/weixin_authorize/client.rb:55:in `http_get_without_token'
    from /var/www/dvoy/shared/bundle/ruby/2.1.0/gems/weixin_authorize-1.0.1/lib/weixin_authorize/client.rb:34:in `authenticate'
    from /var/www/dvoy/shared/bundle/ruby/2.1.0/gems/weixin_authorize-1.0.1/lib/weixin_authorize/client.rb:28:in `get_access_token'
    from /var/www/dvoy/shared/bundle/ruby/2.1.0/gems/weixin_authorize-1.0.1/lib/weixin_authorize/client.rb:65:in `http_post'
    from /var/www/dvoy/shared/bundle/ruby/2.1.0/gems/weixin_authorize-1.0.1/lib/weixin_authorize/api/menu.rb:24:in `create_menu'

应该是之前SSL出现的漏洞导致,RestClient发送post请求出错,sslv3握手失败

微信支付

我按照配置做了之后,统一下单时成功的,但是在jsapi 调用的时候
支付宝错 说 package中的参数partner或prepay_id为空

但是我检查 prepay_id 是有的,
还有个问题,那个 wx_pay.key 到底是什么?我配的是api 秘钥

redis没有存access_token

Q1. 没有存储到redis,不知道什么原因
完全按照指导,添加了文件
screen shot 2015-08-18 at 7 02 07 pm

redis里没用任何key
screen shot 2015-08-18 at 7 02 46 pm

Q2. gem没有说$client在何处初始化,我把$client的初始化放入了weixin_authorize.rb中,是否合适?如果这是一个合适的办法,为什么不默认生成这个文件并初始化client?

Q3. 启动rails server后,直接调用client.access_token返回nil,必须调用is_valid?后,再调用access_token才返回有值,为什么?
screen shot 2015-08-18 at 7 17 37 pm

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.