Skip to content
This repository was archived by the owner on Apr 9, 2020. It is now read-only.
/ oembed Public archive

πŸ“š Golang package for getting oEmbed data from URL

License

Notifications You must be signed in to change notification settings

toby3d/oembed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

42da6d9 Β· May 27, 2019

History

20 Commits
May 23, 2019
May 27, 2019
May 23, 2019
May 24, 2019
May 24, 2019
May 23, 2019
May 24, 2019
May 24, 2019
May 24, 2019
May 27, 2019
May 24, 2019
May 24, 2019
May 24, 2019
May 24, 2019
May 23, 2019
May 23, 2019
May 27, 2019
May 23, 2019
May 27, 2019
May 24, 2019
May 24, 2019
May 27, 2019
May 24, 2019

Repository files navigation

oEmbed

oEmbed is a format for allowing an embedded representation of a URL on third party sites. The simple API allows a website to display embedded content (such as photos or videos) when a user posts a link to that resource, without having to parse the resource directly.

Start using oEmbed

Download and install it:
$ go get -u gitlab.com/toby3d/oembed

Import it in your code:
import "gitlab.com/toby3d/oembed"

Example

package main

import "gitlab.com/toby3d/oembed"

var targetUrl = "https://www.youtube.com/watch?v=8jPQjjsBbIc"

func main() {
  // optional: checks what url has YouTube provider
  if !oembed.HasProvider(targetUrl) {
    return
  }

  // extract oEmbed object of source url
  data, err := oembed.Extract(targetUrl)
  if err != nil {
    // provider not found / source not found / bad response...
    panic(err)
  }

  // use data as you want
}