-1

我是 Ruby 的新手,找到了 ruby​​phone 代码,我试图让它与 xml 一起使用。我已经得到它来查看xml。现在唯一的部分是它错误:test.rb:17: undefined local variable or method `tsapi' for main:Object (NameError)

第 17 行我用 tsapi.new 和 tsapi = tsapi.new 尝试过

任何帮助都会很棒。

require "Win32API"
require "tsapi"
require 'rexml/document'
include REXML
file = File.new("tsapi.xml")
#doc = Document.new(file)
doc = REXML::Document.new('tsapi.xml')
    root=doc.root
    $server = ["section[@name='config']/server"]
    $username = ["section[@name='config']/username"]
    $password = ["section[@name='config']/password"]
    $app = ["section[@name='config']/app"]
    $tracing = ["section[@name='config']/tracing"]


 tsapi.new($extension, $server, $username, $password, $app)
  result == tsapi.open
  if result == true
    #Win32API.new("user32", "MessageBox", ['i','p','p','i'], 'i').call(0, "Calling Voice Mail.", "Calling VMail", 0) if result == true

   result = tsapi.call("12345")
  end
  tsapi.close
4

1 回答 1

0

听起来这个“tsapi”应该是一个类。我不熟悉图书馆,但类以大写字母开头,所以你想要这样的东西:

tsapi = Tsapi.new($extension, $server, $username, $password, $app)

或者

tsapi = TSAPI.new($extension, $server, $username, $password, $app)

或类似的东西,具体取决于实际调用的类。

于 2014-01-21T01:03:37.030 回答