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
 

 

 

 

 

你可能感兴趣的:(C++,c,C#,mobile,Rails)