Code Monkey home page Code Monkey logo

pinterest-node-api's People

Contributors

mjarmoune avatar vijaypatoliya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pinterest-node-api's Issues

Proper paging

I want to retrieve all my pins.
Can you tell how to properly paging through pins using cursor or next url via your library?

Thanking you beforehand for your help!

======================================================================

Figured out, just added cursor property to the data object and passed to the getUserPins(data);

const userToken = "xxxx";
const pinterest = require('pinterest-node-api')(userToken);

pinterest.setUserToken(userToken);

var data = { 
    limit: 100,
    fields: 'image',
    cursor: `'xxxx'
};

try {
    pinterest.pins.getUserPins(data).then(function(result) {
        console.log(result);
    });
} catch (error) {
    return;
}

Thank you for contributing so much!

Authorization failures

import PinterestAPI from 'pinterest-node-api'

this.client = new PinterestAPI()

const ACCESS_TOKEN_SANDBOX =
      'pina_something'
this.client.setUserToken(ACCESS_TOKEN_SANDBOX)

createPin

    var payload = {
      link: tokenDetailsURL,
      title: tokenTitle,
      description: description,
      dominant_color: '#6E7874',
      alt_text: 'string',
      board_id: 'string',
      board_section_id: 'string',
      media_source: {
        source_type: 'image_base64',
        content_type: 'image/jpeg',
        data: 'string',
      },

      parent_pin_id: 'string',
    }
    return this.client.pins
      .create(payload)
      .then((response: any) => {
        console.log('RESPONSE')
        console.log(response)
      })
      .catch((error: any) => {
        console.log('ERROR')
        console.log(error)
      })

Screenshot 2023-09-06 at 22 16 58

error

{ code: 2, message: 'Authentication failed.', status: 'failure' }

Any idea how to resolve this?

setApiKey is not a function

/** Create oauth access token */
var refresh_token_payload = {
grant_type: "refresh_token",
refresh_token: "your refresh token",
};

var authorization_code_payload = {
grant_type: "authorization_code",
code: "code",
redirect_uri: "redirect_uri",
};

/** Set pinterest clientId and clientSecret */
pinterest.setApiKey('clientId', 'clientSecret');

try {
var response = await pinterest.oauth.createAccessToken(
authorization_code_payload || refresh_token_payload
);
} catch (error) {
return;
}

it seems that setApiKey method is not defined and without this line it thorws authentication error code 2.

createBoard didn't work...

Hello, I am testing this library and tried to perform the createBoard call with some test name and description.

Result was an error:

[Error] {
  Type: 'pinterestAPIError',
  Code: 'GenericError',
  Message: 'Invalid response received from the pinterest API',
  StatusCode: 404
}

My code:

var pinterest = require('pinterest-node-api')(process.env.PINTEREST_USER_TOKEN)

exports.createBoard = async ( req, res ) =>
{
    let a = {}
    try 
    {
        let { name, description } = req.body
        var data = {
            name,
            description
          }; 
        var response = await pinterest.boards.createBoard(data);
        res.json( response )
    } catch ( e ) {
        console.log( `createBoard e: `, e )
        res.status( 400 ).json( { error: e, report: a } )
    }
}

I'm using express.js for by backend.

How can I get a successful createBoard call? What was done wrong?

Please let me know the correct way.

Thank you.

How do I search for pins by keyword?

import Pinterest from "pinterest-node-api";
const client = new Pinterest('pina_AMAS3KIWABUBCAA');

  try {
    // Search for pins with the keyword
    const res = await client.request('/pins', {
      method: 'GET',
      params: {
        query: `${keyword} ${modifier}`,
        fields: 'id,note,image'
      }
    });
    const pins = res.data;
  
    // Comment on each pin
    for await (const pin of pins) {
      await client.comment(pin.id, variation);
      console.log(`Commented on pin: https://pinterest.com/pin/${pin.id}`);
    }
  } catch (error) {
    console.error(`Failed to search for or comment on pins. Error: ${error.message}`);
  }

I get client.request is not a function

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.