diff options
author | Debanshu Kundu <debanshu.kundu@joshtechnologygroup.com> | 2017-01-20 23:11:13 +0530 |
---|---|---|
committer | enahum <nahumhbl@gmail.com> | 2017-01-20 14:41:13 -0300 |
commit | 3aaf71fdea914af1a7f2b2fb97bb6ae44132fcc4 (patch) | |
tree | b954407a03a6c0ed9836d8b14d910fc52c8dc1dc /vendor/github.com/dyatlov/go-opengraph/examples/simple.go | |
parent | fefe4b70d9e69910a8e3acd6890497553b5eff2f (diff) | |
download | chat-3aaf71fdea914af1a7f2b2fb97bb6ae44132fcc4.tar.gz chat-3aaf71fdea914af1a7f2b2fb97bb6ae44132fcc4.tar.bz2 chat-3aaf71fdea914af1a7f2b2fb97bb6ae44132fcc4.zip |
#4257 Added functionality to create previews for post links using open graph data from those links. (#4890)
Diffstat (limited to 'vendor/github.com/dyatlov/go-opengraph/examples/simple.go')
-rw-r--r-- | vendor/github.com/dyatlov/go-opengraph/examples/simple.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/vendor/github.com/dyatlov/go-opengraph/examples/simple.go b/vendor/github.com/dyatlov/go-opengraph/examples/simple.go new file mode 100644 index 000000000..fa128cd43 --- /dev/null +++ b/vendor/github.com/dyatlov/go-opengraph/examples/simple.go @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "strings" + + "github.com/dyatlov/go-opengraph/opengraph" +) + +func main() { + html := `<html><head><meta property="og:type" content="article" /> + <meta property="og:title" content="WordPress 4.3 "Billie"" /> + <meta property="og:url" content="https://wordpress.org/news/2015/08/billie/" /></head><body></body></html>` + + og := opengraph.NewOpenGraph() + err := og.ProcessHTML(strings.NewReader(html)) + + if err != nil { + fmt.Println(err) + return + } + + fmt.Printf("Type: %s\n", og.Type) + fmt.Printf("Title: %s\n", og.Title) + fmt.Printf("URL: %s\n", og.URL) + fmt.Printf("String/JSON Representation: %s\n", og) +} |