Skip to content
This repository has been archived by the owner on Nov 1, 2019. It is now read-only.

Latest commit

 

History

History
79 lines (61 loc) · 1.93 KB

README.md

File metadata and controls

79 lines (61 loc) · 1.93 KB

go-pushbullet

Build Coverage API Documentation MIT License

Simple Go client for Pushbullet, a webservice to push links, notes and more to your Android devices.

Documentation available under: http://godoc.org/github.com/xconstruct/go-pushbullet

Install

go get "github.com/xconstruct/go-pushbullet"

Example

pb := pushbullet.New("YOUR_API_KEY")
devs, err := pb.Devices()
if err != nil {
	panic(err)
}

err = pb.PushNote(devs[0].Iden, "Hello!", "Hi from go-pushbullet!")
if err != nil {
	panic(err)
}


user, err := pb.Me()
if err != nil {
	panic(err)
}

err = pb.PushSMS(user.Iden, devs[0].Iden, "<TARGET_PHONE_NUMBER>", "Sms text")
if err != nil {
	panic(err)
}

You can also retrieve a pushbullet device by nickname, and call the same methods as you would with the pushbullet client

dev, err := pb.Device("My Phone")
if err != nil {
	panic(err)
}

err = dev.PushNote("Hello!", "Straight to device with just a title and body")
if err != nil {
	panic(err)
}

Channels are also supported in a similar manner

subs, err := pb.Subscriptions()
if err != nil {
	panic(err)
}

err = pb.PushNoteToChannel(subs[0].Channel.Tag, "Hello!", "Hi from go-pushbullet!")
if err != nil {
	panic(err)
}

sub, err := pb.Subscription("MyChannelTag")
if err != nil {
	panic(err)
}

err = sub.PushNote("Hello!", "Straight to Channel with just a title and body")
if err != nil {
	panic(err)
}