📚 Golang package for getting oEmbed data from URL
gogo-langgolanggolang-librarygolang-modulegolang-packagego-librarygo-modulesgo-packagego-packagesoembed
assets | ||
.gitlab-ci.yml | ||
a_oembed-packr.go | ||
errors.go | ||
fetch_embed.go | ||
fetch_embed_test.go | ||
find_provider.go | ||
find_provider_test.go | ||
go.mod | ||
go.sum | ||
is_valid_url.go | ||
is_valid_url_test.go | ||
LICENSE.md | ||
Makefile | ||
oembed.go | ||
oembed_test.go | ||
patrons.go | ||
README.md | ||
SUPPORT.md | ||
sync.go | ||
sync_test.go | ||
types.go | ||
types_ffjson.go |
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
}