lanrion / weixin_authorize Goto Github PK
View Code? Open in Web Editor NEW微信 Ruby 高级API weixin_authorize http://github.com/lanrion/weixin_authorize .
License: MIT License
微信 Ruby 高级API weixin_authorize http://github.com/lanrion/weixin_authorize .
License: MIT License
自从昨晚凌晨起,restclient Request Timeout的报错信息不停。是不是你那里做了什么改动?
client.authorize_url("jd.cn")
返回信息
=> "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx61e6a632b58abasd1&redirect_uri=jd.cn&response_type=code&scope=snsapi_base&state=weixin#wechat_redirect"
微信服务器怎么没将CODE回传呢?
refactor with Adapter
avatar_cache = gets_image_for_weixin('IP29ABUDaSg26EaZeB3SxGJs04NzQAmqjWpKGVFPWAYYabYVsMDHsXUrMA0ACr6-')
p avatar_cache
什么都打印不出来
先调用 weixin_client.is_valid? 在调用weixin_client.followers ,redis就断了!
报错:
Redis::InheritedError (Tried to use a connection from a child process without reconnecting. You need to reconnect to Redis after forking
http://mp.weixin.qq.com/wiki/index.php?title=全局返回码说明
服务端出错真正返回的是 {"errcode":45009,"errmsg":"api freq out of limit"}。 注意errmsg是英文,第三方开发者还得自己再匹配一次,对一般的企业用户也不太友好。
在官文页面里有个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。
replace multi_json with yajl-ruby
生成字符串参数的永久二维码,参数如果传入options[:scene_str], 则action_name不应是QR_LIMIT_SCENE,而是qrcode_infos = {action_name: "QR_LIMIT_STR_SCENE"},现在好像没这个分支,如果传字符串,扫描时不能返回
ADD-POI-API
您好,感谢贡献先。
我想请教一下,目前有支持处理来自微信的消息、事件推送吗?
http://mp.weixin.qq.com/wiki/index.php?title=高级群发接口
在公众平台网站上,为订阅号提供了每天一条的群发权限,为服务号提供每月(自然月)4条的群发权限。而对于某些具备开发能力的公众号运营者,可以通过高级群发接口,实现更灵活的群发能力。
请注意:
1、该接口暂时仅提供给已微信认证的服务号
2、虽然开发者使用高级群发接口的每日调用限制为100次,但是用户每月只能接收4条,请小心测试
3、无论在公众平台网站上,还是使用接口群发,用户每月只能接收4条群发消息,多于4条的群发将对该用户发送失败。
1.调用media_url,返回空
2.调用WeixinAuthorize::Client.new,is_valid?返回false
调用reply_image_message没有任何反应?
调用reply_text_message可以收到。
部分API名称不够贴近。
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
我跟着 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×tamp=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
我在交流群里问了几个朋友都不知道怎么回事…
不知道我代码哪儿出了问题,能给思路吗?
调用is_valid?,正常
调用followers,报错
{"errcode"=>40001, "errmsg"=>"invalid credential"}
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
我有什么地方想错了?
https://github.com/lanrion/weixin_authorize/blob/OAuth2/lib/weixin_authorize/client.rb#L23
如果test环境下没有配置app_id等参数,执行rspec
时会导致进程抛异常后中断。这个是否需要修复?
异常:
bundler/gems/weixin_authorize-2f9295f79c99/lib/weixin_authorize/client.rb:23:in `+': no implicit conversion of nil into String (TypeError)
1.6.0 是没有这个接口的,你没有升级版本吗?
1.接口说明不完善,比如比如file_url(这是只本地,如果是url了?)
2.调用后返回,responce.result 为 {} (调用成功后没有返回任何东西)
微信卡券由于参数过多,构建Json时,需要传入很多参数。
而官方提供的接口参数文档结构层次不明晰,因此特别整理了一个 API Map 方便各位做开发
微信卡券API基本结构为(详见):
请问,现在的提供的API里有发送模板消息的功能吗?
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握手失败
$client ||= WeixinAuthorize::Client.new(ENV["APPID"], ENV["APPSECRET"])
如果不做成全局变量,每次client都重新获取,会不会每次都向微信服务器发送请求
如果是全局变量,在rails中放在哪里比较好?
似乎在 access_token 过期后会出现
Tried to use a connection from a child process without reconnecting. You need to reconnect to Redis after forking.
的问题
请问是插件逻辑不完善还是我配置有问题?
使用配置cache store
提供一个验证方法或者直接返回错误码
我按照配置做了之后,统一下单时成功的,但是在jsapi 调用的时候
支付宝错 说 package中的参数partner或prepay_id为空
但是我检查 prepay_id 是有的,
还有个问题,那个 wx_pay.key 到底是什么?我配的是api 秘钥
详见:获取自动回复规则
目前提供的对象存储、redis存储,无法满足多种业务需求。
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(接口调用超过限制).):
2.2.0 :003 > client.http_post
NoMethodError: private method `http_post' called for #WeixinAuthorize::Client:0x007f85d4f17230
https://github.com/lanrion/qy_wechat_api
每个类别的接口由一个类来统筹。
Hi,
我在最近的使用中发现一个问题,如view类型的url字段包含&,则在Json.load后转移成了\u0026形式的unicode,可能会导致成功的提交 menu create的请求。
本人的环境是rails 4.0,编码为UTF8。不知道是不是一个偶发性的问题。
我直接利用wget下在了jssdk上传的图片,然后carrierwave做了处理,貌似render到页面的时候访问不到啊
weixin_authorize依赖于yajl-ruby,而yajl-ruby是基于C的扩展,在JRuby环境中不能安装。请问可否使用yajl-ruby的替代gem从而增加对JRuby的支持?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.