vijaypatoliya / pinterest-node-api Goto Github PK
View Code? Open in Web Editor NEWPinterest-Node-API (Pinterest Node Rest API)
License: MIT License
Pinterest-Node-API (Pinterest Node Rest API)
License: MIT License
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!
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)
})
error
{ code: 2, message: 'Authentication failed.', status: 'failure' }
Any idea how to resolve this?
/** 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.
Is there a way to auto renew access token?
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.
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
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.