realadeel / pinterest-api Goto Github PK
View Code? Open in Web Editor NEWRuby gem to interact with the official Pinterest REST API
License: MIT License
Ruby gem to interact with the official Pinterest REST API
License: MIT License
Pinterest started to return detailed user data with Version 3, base endpoint should be conditional for user object and make the call to "https://api.pinterest.com/v3/"
Pinterest's API requires uploading the image via a form data POST call. The gem currently does not support that behavior so either the image_url
or image_base64
. It would be nice if the gem could support the image
option as well. See https://developers.pinterest.com/docs/api/pins
When I issue a request to the gem to get my private boards with get_boards
method I get the strange answer:
{"data"=>[],
"page"=>
{"cursor"=>"b28yNXxmMGVmZDA5YjB5Yjk5NDIxZjgzODZjNDRkZWEzNTRhZmIyZDRjZjE3ZWY4YmRmMWE4NmVhZGQwNDg1NTNmOTAw",
"next"=>
"https://api.pinterest.com/v1/me/search/pins/?access_token=ATn4phEFgj31x3eaA1tgFLeknE7MFQ0LI9ZTHe5Epzcd5oAzhAAAAAA&query=Agnetis&cursor=b28yNXxmMGVmZDA5YjA5Yjk5NDIxZjgzODZjNDRkZWEzNTRhZmIyZDRjZjE3ZWY4YmRmMWE4NmVhZGQwNDg1NTNmOTAw"}}
The documentation https://developers.pinterest.com/docs/api/boards/ give not the same answer as I get from the method above.
So the question is how to use the method properly?
Hello, github has notified me that pinterest-api is depending on a vulnerable version of the omniauth-oauth2 gem. You can find the vulnerability of omniauth-oauth2 here: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2012-6134
Is there a way to upgrade the version?
I have the following rake task to pin images to Pinterest
namespace :pinterest_product_images do
desc 'pin product iamges to pinterest'
task pin: :environment do
client = Pinterest::Client.new(PINTEREST_CONFIG[:access_token])
Spree::Product.find_each(conditions: { published: true }) do |product|
product_image = product.images.first.try(:attachment)
if product_image
file_path = File.expand_path('') + "/#{product_image.path(:original)}"
content_type = product_image.content_type
if file_path && content_type
resp = client.create_pin({ board: '<my board id>',
note: "#{product.name} MyApp #{product.category}",
link: "#{PINTEREST_CONFIG[:host]}/products/#{product.slug}",
image: Faraday::UploadIO.new(file_path, content_type)
})
puts "path: #{file_path}, type: #{content_type} => #{resp[:message]}" if resp[:message]
Rails.logger.info "Pinterest Response: #{resp}"
end
end
end
end
end
I am getting the following output
path: /home/my-name/Desktop/my-site/public/my-assets/products/4/original/sample1.jpg, type: image/jpeg => You need to upload an image or provide the 'image_url' parameter
path: /home/my-name/Desktop/my-site/public/my-assets/products/1/original/sample2.jpg, type: image/jpeg => You need to upload an image or provide the 'image_url' parameter
path: /home/my-name/Desktop/my-site/public/my-assets/products/3/original/sample3.jpg, type: image/jpeg => You need to upload an image or provide the 'image_url' parameter
path: /home/my-name/Desktop/my-site/public/my-assets/products/2/original/sample4.JPG, type: image/jpeg => You need to upload an image or provide the 'image_url' parameter
path: /home/my-name/Desktop/my-site/public/my-assets/products/1/original/sample5.jpg, type: image/jpeg => You need to upload an image or provide the 'image_url' parameter
$ ruby -v
ruby 2.1.8p440 (2015-12-16 revision 53160) [x86_64-linux]
$ rails -v
Rails 4.0.13
Hi @realadeel
i want to get authorization code without popups to pinterest.com site . because in my network cannot visit pinterest.com host . but i have a server can visit that host .
so do you have any way to help me resolve this issue?
thanks .
The 0.4.0 version has an old faraday dependency. It'd be great to update it.
Hi,
It seems like Pinterest is only interested in redirect URI's with "https" rather than "http".
Is there a way for me to edit the redirect URI for pinterest-api?
I am thinking about a port forwarding address with ngrok. The developer would customize callback url to random address such as "https://15f03ea4.ngrok.io" which would forward to the original wanted address such as http://localhost:3000/auth/pinterest/callback
Thank You
For proper error handling we want to rely on the http status codes which pinterest api gives back: https://developers.pinterest.com/docs/api/overview/#errors
Currently in https://github.com/realadeel/pinterest-api/blob/master/lib/pinterest/client.rb#L60 only the response body will be returned.
An example response:
[2] pry(#<Onlim::Adapter::Publish::Link::Pinterest>)> response
=> {"status"=>"failure", "code"=>3, "host"=>"devplatform-devapi-prod-f7410648", "generated_at"=>"Wed, 26 Oct 2016 09:19:28 +0000", "message"=>"Authorization failed.", "data"=>nil}
We want to rely on the documented http return status codes instead of relying on the code which is returned in the body (didn't find documentation about this code).
Are there any problems in returning the whole response?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.