rails飞信 gem plugin api 插件的问题解决方案

 

 

C:\>gem install rfetion
Successfully installed macaddr-1.0.0
Successfully installed uuid-2.0.2
Successfully installed rfetion-0.3.4
3 gems installed


要装这么多gem包,如果用虚拟主机的话有时可能有点麻烦

 


我觉得用plugin 还好方便管理些 把那三个gem 包都卸了
用rfetion 与guid 这两人个插件就可以了
因此rfetion插件中  lib\rfetion.rb文件第二行要注释掉

 

#lib\rfetion.rb文件第2行
#require 'uuid'

 

 

    #lib\rfetion\fetion.rb 中第12行 要注释掉并换成

#lib\rfetion\fetion.rb 中第12行 要注释掉并换成


#  GUID = UUID.new.generate
  require 'uuidtools'
  GUID = UUID.random_create.to_s


同时第24行要换成


  def calc_cnonce
    Digest::MD5.hexdigest(GUID).upcase
  end

 

 

这样就可以了

 

下面是两人个正确的插件包

 

如果好友列表中有 不公开手机号的好友可能匹配错误以下方案可以解决

 

 

 

 

 
#lib\rfetion\fetion.rb 中get_contacts_info 的正则 修改下下

def get_contacts_info
    @logger.info "fetion get contacts info"
    arg = '<args><contacts attributes="all">'
    @buddies.each do |buddy|
      arg += "<contact uri=\"#{buddy[:uri]}\" />"
    end
    arg += '</contacts></args>'

    msg = sip_create('S fetion.com.cn SIP-C/2.0', {'F' => @sid, 'I' => next_call, 'Q' => '1 S', 'N' => 'GetContactsInfo'}, arg) + FETION_SIPP
    curl_exec(next_url, @ssic, msg)
    response = curl_exec(next_url, @ssic, FETION_SIPP)
    raise FetionException.new("Fetion Error: Get contacts info error") unless response.is_a? Net::HTTPSuccess

    #    response.body.scan(/uri="([^"]+)".*?mobile-no="([^"]+)"/).each do |contact|
    #      @contacts << {:sip => contact[0], :mobile_no => contact[1]}
    #    end
    response.body.scan(/<contact.*?<\/contact>/).each do |contact|
      #      @contacts << {:sip => contact[0], :mobile_no => contact[1]}
      contact.scan(/uri="([^"]+)"/).each do |sip|
        @contacts << {:sip => sip[0]}
      end
      contact.scan(/uri="([^"]+)".*?mobile-no="([^"]+)"/).each do |sip|
        @contacts.delete_if{ |c| c.has_value?(sip[0]) }
        @contacts << {:sip => sip[0], :mobile_no => sip[1]}

      end

    end
    #    @logger.info " response.body"
    #    @logger.info  response.body
    @logger.info @contacts.inspect
    @logger.info "fetion get contacts info success"
  end
 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值