Installation
Add this line to your application's Gemfile:
gem 'postwill'
And then execute:
$ bundle
Single provider
postwill = Postwill::Client.new(
twitter: {
access_token: 'access_token',
access_token_secret: 'access_token_secret'
}
)
postwill.to(:twitter, text: 'text', image: 'image')
Success:
{
twitter: {
status: :ok,
response: {}
}
}
Failure:
{
twitter: {
status: :error,
response: ''
}
}
Application credentials (for providers which need them)
config/initializers/postwill.rb
Postwill::Settings.configure do |config|
config.providers.twitter = {
consumer_key: 'your_consumer_key',
consumer_secret: 'your_consumer_secret'
}
end
Multiple providers
postwill = Postwill::Client.new(
twitter: {
access_token: 'access_token',
access_token_secret: 'access_token_secret'
},
facebook: {
access_token: 'access_token'
}
)
postwill.to(%i[twitter facebook], text: 'text', image: 'image')
Result:
{
twitter: {
status: :ok,
response: {}
},
facebook: {
status: :ok,
response: {}
}
}
Based on: Twitter
postwill = Postwill::Client.new(
twitter: {
access_token: 'access_token',
access_token_secret: 'access_token_secret'
}
)
postwill.to(:twitter, text: 'text', image: 'image')
Success:
{
twitter: {
status: :ok,
response: {}
}
}
Failure:
{
twitter: {
status: :error,
response: ''
}
}
Settings:
Postwill::Settings.configure do |config|
config.providers.twitter = {
consumer_key: 'your_consumer_key',
consumer_secret: 'your_consumer_secret'
}
end
Facebook
Based on: Koala
postwill = Postwill::Client.new(
facebook: {
access_token: 'access_token'
}
)
postwill.to(:facebook, text: 'text', image: 'image')
Success:
{
facebook: {
status: :ok,
response: {}
}
}
Failure:
{
facebook: {
status: :error,
response: ''
}
}
Pinterest
Based on: PinterestApi
postwill = Postwill::Client.new(
pinterest: {
access_token: 'access_token'
}
)
postwill.to(:pinterest, text: 'text', image: 'image', board_id: 'board_id', link: 'link')
postwill.to(:pinterest, text: 'text', image_url: 'image_url', board_id: 'board_id', link: 'link')
Success:
{
pinterest: {
status: :ok,
response: {
'data' => {
'url' => 'PIN_LINK',
'note' => 'text',
'link' => 'LINK',
'id' => 'PIN_ID'
}
}
}
}
Failure:
{
pinterest: {
status: :error,
response: ''
}
}
Tumblr
Based on: TumblrClient
postwill = Postwill::Client.new(
tumblr: {
access_token: 'access_token',
access_token_secret: 'access_token_secret'
}
)
postwill.to(:tumblr, text: 'text', image: 'image', user: 'user_nickname')
postwill.to(:tumblr, text: 'text', title: 'title', user: 'user_nickname')
Success:
{
tumblr: {
status: :ok,
response: {
{
'id' => 'POST_ID'
}
}
}
}
Failure:
{
tumblr: {
status: :error,
response: ''
}
}
Settings:
Postwill::Settings.configure do |config|
config.providers.tumblr = {
consumer_key: 'consumer_key',
consumer_secret: 'consumer_secret'
}
end
Instagram
Based on: InstagramUpload
postwill = Postwill::Client.new(
instagram: {
username: 'username',
password: 'password'
}
)
postwill.to(:instagram, text: 'text', image: 'image')
Success:
{
instagram: {
status: :ok,
response: {}
}
}
Failure:
{
instagram: {
status: :error,
response: ''
}
}