使用Rest Client时未定义的方法`request_uri'错误 - 尝试使用Facebook Graph删除

时间:2011-04-10 07:59:52

标签: ruby-on-rails facebook facebook-graph-api rest-client

我可以尝试使用Rest Client使用Facebook Graph删除对象。

def delete_object
    temp = url_escape('https://graph.facebook.com/'+request_id+'?access_token='+token)
    p "temp is"
    p temp
    delete_attempt = RestClient.delete temp
end

private

def url_escape(string)
    string.gsub(/([^ a-zA-Z0-9_.-]+)/n) do
        '%' + $1.unpack('H2' * $1.size).join('%').upcase
    end.tr(' ', '+')
end

控制台输出:

temp is
"https%3A%2F%2Fgraph.facebook.com%2Fobject_id_here%3Faccess_token%3Daccess_token_here"

object_id_here& access_token_here在此处用作占位符,值是正确的。

我收到此错误:

undefined method `request_uri' for #<URI::Generic:0x00000104385a40>
/Users/ben/.rvm/gems/ruby-1.9.2-p0/gems/rest-client-1.6.1/lib/restclient/request.rb:60:in `execute'\n/
Users/ben/.rvm/gems/ruby-1.9.2-p0/gems/rest-client-1.6.1/lib/restclient/request.rb:31:in `execute'\n/
Users/ben/.rvm/gems/ruby-1.9.2-p0/gems/rest-client-1.6.1/lib/restclient.rb:80

request.rb中的第60行是Rest Client中此方法中的transmit uri...行:

def execute & block
    uri = parse_url_with_auth(url)
    transmit uri, net_http_request_class(method).new(uri.request_uri, processed_headers), payload, & block
end

导致此错误的原因是什么?

0 个答案:

没有答案