OpenGraph (ogp v1.1.1)

Summary

Functions

Fetch URL and parse Open Graph protocol.

Similar to fetch/2 but raises an OpenGraph.Error if request failed.

Parse Open Graph protocol.

Types

@type t() :: %OpenGraph{
  audio: value(),
  description: value(),
  determiner: value(),
  image: value(),
  locale: value(),
  site_name: value(),
  title: value(),
  type: value(),
  url: value(),
  video: value()
}
@type url() :: URI.t() | String.t()
@type value() :: String.t() | nil

Functions

Link to this function

fetch(url, req_options \\ [])

@spec fetch(url(), req_options :: keyword()) ::
  {:ok, t()} | {:error, OpenGraph.Error.t()}

Fetch URL and parse Open Graph protocol.

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

Link to this function

fetch!(url, req_options \\ [])

@spec fetch!(url(), req_options :: keyword()) :: t()

Similar to fetch/2 but raises an OpenGraph.Error if request failed.

Returns %OpenGraph{}.

@spec parse(String.t()) :: t()

Parse Open Graph protocol.

Returns %OpenGraph{}.

Examples

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