pinterest/pinterest-api-demo

Name: pinterest-api-demo

Owner: Pinterest

Description: null

Created: 2015-09-23 23:03:44.0

Updated: 2018-05-06 18:06:42.0

Pushed: 2018-03-25 21:30:15.0

Homepage: null

Size: 94

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Pinterest API Demo

A client for saving Instagram posts to Pinterest.

View the demo here

It is really simple to interact with the new developer API by using the Pinterest Javascript SDK. It provides shorthands for accessing endpoints, and more importantly, provides one-line solutions for oauth authentication with Pinterest.

login({ scope : PIN_SCOPE }, callback);
logout();

The callback contains a session object that can also be accessed via PDK.getSession(). If a user is not authenticated, the function returns undefined. The scope is related to what kind of access your app would like (read_public, write_public, read_relationships, write_relationships). Scope is a comma-delimited list of requested types.

Demo functions

Here are the methods being used in this demo application:

| Code | Response | Description | | ————- |:————-:| ————:| | PDK.login({ scope : PIN_SCOPE }, callback) | { accessToken } | Opens an oauth login popup | | PDK.logout() | none | Deletes the session/cookie | | PDK.request('/pins/', 'POST', data, callback) | { data: {id,link,note,url }| Creates a new pin object | | PDK.me('boards', { fields: PIN_FIELDS }, callback) | { data: [board, …] } | Fetches the current user's boards |

Examples

Here is code found directly in /src/js/util/pinterest.js of the demo app. They are clear examples of how to use the SDK to interact with the developer API.


Use SDK to create a new Pin
@param {Object}   data     - {board, note, link, image_url}
@param {Function} callback - function fired on completion

tePin: function(data, callback) {
PDK.request('/pins/', 'POST', data, callback);

avascript

Use SDK to request current users boards
@param {Function} callback - function fired on completion

ards: function(callback) {
PDK.me('boards', { fields: Const.PIN_FIELDS }, callback);


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.