2

我正在尝试在此 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

谢谢阅读。

4

2 回答 2

1

尝试转义access_token

url = 'https://graph.facebook.com/me/home?access_token=' + URI.escape(access_token)
于 2010-11-02T05:47:39.463 回答
0
r = RestClient.get 'https://graph.facebook.com/me/feed', :params => {:access_token => access_token }

你应该做这样的事情

于 2012-04-02T06:42:58.250 回答