Class: ArticleJSON::Utils::OEmbedResolver::FacebookVideo

Inherits:
Base
  • Object
show all
Defined in:
lib/article_json/utils/o_embed_resolver/facebook_video.rb

Instance Method Summary collapse

Methods inherited from Base

build, #initialize, #oembed_data, resolver_by_embed_type, #unavailable_message

Constructor Details

This class inherits a constructor from ArticleJSON::Utils::OEmbedResolver::Base

Instance Method Details

#access_tokenString

The facebook access token. If not set, it raises an exception explaining how to configure it.

Returns:

  • (String)


28
29
30
31
32
33
34
35
36
37
# File 'lib/article_json/utils/o_embed_resolver/facebook_video.rb', line 28

def access_token
  token = ArticleJSON.configuration.facebook_token

  if token.nil?
    raise 'You need to configure the facebook token to use facebook' \
          'embed videos, see:' \
          'https://github.com/Devex/article_json#facebook-oembed'
  end
  token
end

#nameString

Human readable name of the resolver

Returns:

  • (String)


7
8
9
# File 'lib/article_json/utils/o_embed_resolver/facebook_video.rb', line 7

def name
  'Facebook video'
end

#oembed_urlString

The URL for the oembed API call

Returns:

  • (String)


13
14
15
16
# File 'lib/article_json/utils/o_embed_resolver/facebook_video.rb', line 13

def oembed_url
  "https://graph.facebook.com/v9.0/oembed_video?url=#{source_url}" \
  "&access_token=#{access_token}"
end

#source_urlString

The video URL of the element

Returns:

  • (String)


20
21
22
# File 'lib/article_json/utils/o_embed_resolver/facebook_video.rb', line 20

def source_url
  "https://www.facebook.com/facebook/videos/#{@element.embed_id}"
end