Skip to content

Commit

Permalink
Add sample application
Browse files Browse the repository at this point in the history
  • Loading branch information
thebaer committed Apr 22, 2019
1 parent f190dda commit 0872cfb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions sample/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sample
28 changes: 28 additions & 0 deletions sample/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package main

import (
"fmt"
"github.com/writeas/go-ghost"
"github.com/writeas/go-ghost/admin"
"os"
)

func main() {
if len(os.Args) != 3 {
fmt.Fprintf(os.Stderr, "usage: sample GHOST_URL API_KEY\n")
os.Exit(1)
}

url := os.Args[1]
apiKey := os.Args[2]

c := ghost.NewClient(url, apiKey)
err := admin.AddPost(c, ghost.PostParams{
Title: ghost.String("Posting via Go"),
Markdown: ghost.String(`This is a **test post** made with the [go-ghost](https://github.com/writeas/go-ghost) library.`),
Status: ghost.String("published"),
})
if err != nil {
fmt.Printf("AddPost: %v\n", err)
}
}

0 comments on commit 0872cfb

Please sign in to comment.