Rails 3.1-Facebook页面API调用

Rails 3.1-Facebook页面API调用,facebook,ruby-on-rails-3,facebook-graph-api,ruby-on-rails-3.1,Facebook,Ruby On Rails 3,Facebook Graph Api,Ruby On Rails 3.1,我有以下功能,可以很好地使用简单的URL访问Facebook页面:www.Facebook.com/TurbonegroHQ def get_facebook @artist = Artist.accessible_by(current_ability).find(params[:id]) if @artist.facebook_url.present? require 'open-uri' require 'json' result =

我有以下功能,可以很好地使用简单的URL访问Facebook页面:www.Facebook.com/TurbonegroHQ

  def get_facebook
    @artist = Artist.accessible_by(current_ability).find(params[:id])
    if @artist.facebook_url.present?
      require 'open-uri'
      require 'json'
      result = JSON.parse(open("https://graph.facebook.com/"<<@artist.facebook_url).read)
      @hometown = result["hometown"]
      @band_members = result["band_members"]
      @likes = result["likes"]
    end
  end
def get_facebook
@艺术家=艺术家。可由(当前能力)访问。查找(参数[:id])
如果@artist.facebook\u url.present?
需要“打开uri”
需要“json”

result=JSON.parse(打开https://graph.facebook.com/“
TurbonegroHQ
是页面的用户名-这可以与Graph API中的对象ID互换

如果页面没有用户名,则需要通过ID访问。在这种情况下,是要访问的URL

通常情况下,在我能想到的所有端点上,都会在API中返回ID,而不是URL