In last blog we have implemented pinterest authentication. Now, we will implement posting on pinterest.
2.) We will do post on pinterest with pinterest-api gem
So, in Gemfile -
gem 'pinterest-api'
run bundle
From last blog we can get token from pinterest_callback with the help of this method we can initialize the client for pinterest api-
In Model pinterest.rb -
def initialize_pinterest_client
@client = Pinterest::Client.new(token) #Get token from pinterest authentication.
end
For posting on pintesert we have to create pinterest board.
def create_pinterset_board(board_name)
@client = initialize_pinterest_client
board_id = @client.create_board({name: board_name}).data.id
end
Now, we can create pin on pinterest -
def post_to_pinterest(product)
@client = initialize_pinterest_client
@client.create_pin({board: board_id, note: post_name, link: url, image_url: image_url})
end
2.) We will do post on pinterest with pinterest-api gem
So, in Gemfile -
gem 'pinterest-api'
run bundle
From last blog we can get token from pinterest_callback with the help of this method we can initialize the client for pinterest api-
In Model pinterest.rb -
def initialize_pinterest_client
@client = Pinterest::Client.new(token) #Get token from pinterest authentication.
end
For posting on pintesert we have to create pinterest board.
def create_pinterset_board(board_name)
@client = initialize_pinterest_client
board_id = @client.create_board({name: board_name}).data.id
end
Now, we can create pin on pinterest -
def post_to_pinterest(product)
@client = initialize_pinterest_client
@client.create_pin({board: board_id, note: post_name, link: url, image_url: image_url})
end
No comments:
Post a Comment