尝试使用rest_client在Facebook API上执行简单的GET HTTP请求,但它不接受该URL,即使该URL工作正常
我正在尝试获取此网址处的数据:
https://graph.facebook.com/me?access_token=(my access token)
当我在浏览器中访问此地址时,它可以工作。但我正在尝试在 Ruby on Rails 中使用 rest-client gem,如下所示:
url = 'https://graph.facebook.com/me/home?access_token=' + access_token
result = RestClient.get url
p result
但是我收到此错误消息:
URI::InvalidURIError in AuthenticationsController#index
bad URI(is not URI?): https://graph.facebook.com/me/home?access_token=(my access token)
我在这里做错了什么?会不会和access_token的格式有关系?我在上面的代码中省略了它,但这就是它的格式:
1xxx
感谢您的阅读。
I'm trying to get the data at this url:
https://graph.facebook.com/me?access_token=(my access token)
When I go to this address in a browser, it works. But I'm trying to use the rest-client gem in Ruby on Rails like this:
url = 'https://graph.facebook.com/me/home?access_token=' + access_token
result = RestClient.get url
p result
But I get this error message:
URI::InvalidURIError in AuthenticationsController#index
bad URI(is not URI?): https://graph.facebook.com/me/home?access_token=(my access token)
What am I doing wrong here? Could it have something to do with the format of the access_token? I've left it out in the code above, but this is the format it's in:
1xxx
Thanks for reading.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试转义
access_token
:Try escaping the
access_token
:你应该做这样的事情
You should do something like this