未定义方法“request_uri”使用 Rest Client 时出错 - 尝试使用 Facebook Graph 删除
我可以尝试使用 Rest Client 使用 Facebook 图。
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 是 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
导致此错误的原因是什么?
I can trying to use Rest Client to delete an object using the 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
Console output:
temp is
"https%3A%2F%2Fgraph.facebook.com%2Fobject_id_here%3Faccess_token%3Daccess_token_here"
object_id_here
& access_token_here
used as placeholders here, the values are correct.
I get this error:
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
Line 60 in request.rb is the transmit uri...
line in this method in Rest Client:
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
What is causing this error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论