openid出错

chenlw_dev
guange 10 years ago
parent f098e5358d
commit 3a0f98ebea

@ -118,7 +118,7 @@ class WechatsController < ActionController::Base
on :fallback, respond: 'fallback message' on :fallback, respond: 'fallback message'
on :click, with: 'MY_NEWS' do |request, key| on :click, with: 'MY_NEWS' do |request, key|
if user_binded? if user_binded?(request[:FromUserName])
news = (1..count.to_i).each_with_object([]) { |n, memo| memo << { title: 'News title', content: "No. #{n} news content" } } news = (1..count.to_i).each_with_object([]) { |n, memo| memo << { title: 'News title', content: "No. #{n} news content" } }
request.reply.news(news) do |article, n, index| # article is return object request.reply.news(news) do |article, n, index| # article is return object
article.item title: "#{index} #{n[:title]}", description: n[:content], pic_url: 'http://www.baidu.com/img/bdlogo.gif', url: 'http://www.baidu.com/' article.item title: "#{index} #{n[:title]}", description: n[:content], pic_url: 'http://www.baidu.com/img/bdlogo.gif', url: 'http://www.baidu.com/'
@ -156,8 +156,7 @@ class WechatsController < ActionController::Base
end end
private private
def user_binded? def user_binded?(openid)
openid = request[:FromUserName]
uw = UserWechat.where(openid: openid).first uw = UserWechat.where(openid: openid).first
end end
end end

Loading…
Cancel
Save