GithubHelp home page GithubHelp logo

isabella232 / pinterest-api-demo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pinterest/pinterest-api-demo

0.0 0.0 0.0 97 KB

License: Apache License 2.0

HTML 7.84% JavaScript 58.42% CSS 33.73%

pinterest-api-demo's Introduction

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.

PDK.login({ scope : PIN_SCOPE }, callback);
PDK.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
 */
createPin: function(data, callback) {
    PDK.request('/pins/', 'POST', data, callback);
}
/*
 *  Use SDK to request current users boards
 *  @param {Function} callback - function fired on completion
 */
myBoards: function(callback) {
    PDK.me('boards', { fields: Const.PIN_FIELDS }, callback);
}

pinterest-api-demo's People

Contributors

jparise avatar zackargyle avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.