OpenGraph (ogp v1.0.2)

Link to this section Summary

Functions

Fetch URL and parse Open Graph protocol.

Similar to fetch/1 but raises a OpenGraph.Error exception if request failed.

Parse Open Graph protocol.

Link to this section Types

Specs

t() :: %OpenGraph{
  audio: value(),
  description: value(),
  determiner: value(),
  image: value(),
  locale: value(),
  site_name: value(),
  title: value(),
  type: value(),
  url: value(),
  video: value()
}

Specs

value() :: String.t() | nil

Link to this section Functions

Specs

fetch(String.t()) :: {:ok, t()} | {:error, OpenGraph.Error.t()}

Fetch URL and parse Open Graph protocol.

Returns {:ok, %OpenGraph{}} for succussful request, otherwise, returns {:error, %OpenGraph.Error{}}.

Specs

fetch!(String.t()) :: t()

Similar to fetch/1 but raises a OpenGraph.Error exception if request failed.

Returns %OpenGraph{}.

Specs

parse(String.t()) :: t()

Parse Open Graph protocol.

Returns %OpenGraph{}.

Examples

iex> OpenGraph.parse("<meta property='og:title' content='GitHub' />")
%OpenGraph{title: "GitHub"}