Package 'opengraph'

Title: Process Metadata from the Open Graph Protocol
Description: Social media sites often embed cards when links are shared, based on metadata in the 'Open Graph Protocol' (<https://ogp.me/>). This supports extracting that metadata from a website. It further allows for the creation of tags to add to a website to support the 'Open Graph Protocol' and provides a list of the standard tags and their required properties.
Authors: Christopher T. Kenny [aut, cre]
Maintainer: Christopher T. Kenny <[email protected]>
License: MIT + file LICENSE
Version: 0.0.2
Built: 2024-12-10 22:54:26 UTC
Source: CRAN

Help Index


Create Open Graph meta tags

Description

Create Open Graph meta tags

Usage

og_create(title, type, image, url, ...)

Arguments

title

The title of your object as it should appear within the graph

type

The type of your object, e.g., "video.movie". Depending on the type you specify, other properties may also be required.

image

An image URL which should represent your object within the graph.

url

The canonical URL of your object that will be used as its permanent ID in the graph

...

Additional Open Graph properties

Value

A character vector of Open Graph meta tags

Examples

og_create(
  title = 'Process the Open Graph Protocol',
  type = 'website',
  image = 'http://christophertkenny.com/opengraph/logo.png',
  url = 'https://christophertkenny.com/opengraph/',
  description = 'Parse metadata on websites which use the Open Graph Protocol.'
)

Parse Open Graph Metadata

Description

Parse Open Graph Metadata

Usage

og_parse(url)

Arguments

url

A string representing the URL of the webpage to parse.

Value

A named vector of Open Graph metadata.

Examples

og_parse('https://www.rstudio.com')

Extract a specific Open Graph property from a webpage.

Description

Extract a specific Open Graph property from a webpage.

Usage

og_property(url, property)

Arguments

url

A string representing the URL of the webpage to parse.

property

A string indicating the Open Graph property (e.g., "og:title" or "title").

Value

A string containing the value of the specified property, or NA if not found.

Examples

og_property('https://www.rstudio.com', 'og:title')

Open Graph Schema

Description

As of 2024-12-05. Based on https://ogp.me/

Usage

og_schema

Format

A list of Open Graph schema.

Examples

og_schema

Validate Open Graph Metadata

Description

Check if all required Open Graph properties are present.

Usage

og_validate(metadata)

Arguments

metadata

A named list of Open Graph metadata.

Value

A logical value indicating whether all required metadata is present.

Examples

og_parse('https://www.rstudio.com') |>
  og_validate()