发布博客500问题

chenlw_dev
huang 9 years ago
parent cd9ad535f5
commit f951d22d56

@ -78,40 +78,44 @@ class BlogComment < ActiveRecord::Base
#博客回复微信模板消息 #博客回复微信模板消息
def blog_wechat_message def blog_wechat_message
uw = UserWechat.where(user_id: self.parent.author_id).first # 发布博客
#unless uw.nil? && self.parent.author_id != User.current.id unless self.parent_id.nil?
unless uw.nil? uw = UserWechat.where(user_id: self.parent.author_id).first
data = { #unless uw.nil? && self.parent.author_id != User.current.id
touser:uw.openid, unless uw.nil?
template_id:"A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c", data = {
url:"http://weixin.qq.com/download", touser:uw.openid,
topcolor:"#FF0000", template_id:"A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c",
data:{ url:"http://weixin.qq.com/download",
first: { topcolor:"#FF0000",
value:"您的博客有新回复了", data:{
color:"#173177" first: {
}, value:"您的博客有新回复了",
keyword1:{ color:"#173177"
value:self.author.try(:realname), },
color:"#173177" keyword1:{
}, value:self.author.try(:realname),
keyword2:{ color:"#173177"
value:format_time(self.created_at), },
color:"#173177" keyword2:{
}, value:format_time(self.created_at),
keyword3:{ color:"#173177"
value:self.content.html_safe, },
color:"#173177" keyword3:{
}, value:self.content.html_safe,
remark:{ color:"#173177"
value:"具体内容请点击详情查看网站", },
color:"#173177" remark:{
} value:"具体内容请点击详情查看网站",
} color:"#173177"
} }
logger.info "start send template message: #{data}" }
req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data) }
logger.info "send over. #{req}" logger.info "start send template message: #{data}"
req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data)
logger.info "send over. #{req}"
end
end end
end end
end end

Loading…
Cancel
Save