Skip to content
This repository has been archived by the owner on Dec 30, 2020. It is now read-only.

Latest commit

 

History

History
352 lines (267 loc) · 8.5 KB

pins.md

File metadata and controls

352 lines (267 loc) · 8.5 KB

Pins

Notice! Try not to be very aggressive when pinning or commenting pins, or Pinterest will gonna ban you.

Pin info

Get pin info by its id:

$info = $bot->pins->info(1234567890);

Create a pin

Create new pin. Accepts image url, board id, where to post image, description and preview url:

$pinInfo = $bot->pins->create('http://exmaple.com/image.jpg', $boardId, 'Pin description');
print_r($pinfInfo['id']);

You can pass a path to your local image. It will be uploaded to Pinterest:

$pinInfo = $bot->pins->create('image.jpg', $boardId, 'Pin description');

You can specify a link for pin (source) as fourth argument. If not set, link is equal to image url:

$pinInfo = $bot->pins->create(
    'http://exmaple.com/image.jpg', 
    $boardId, 
    'Pin description',
    'http://site.com',
);

If you have Rich Pins enabled, you can specify a title of the pin:

$pinInfo = $bot->pins->create(
    'http://exmaple.com/image.jpg',
    $boardId,
    'Pin description',
    'http://site.com',
    'Pin title'
);

You can specify a board section id as the last argument:

$pinInfo = $bot->pins->create(
    'http://exmaple.com/image.jpg',
    $boardId,
    'Pin description',
    'http://site.com',
    'Pin title'
    $sectionId,
);

Repin

Repin a pin by its id. You need a pin id and a board id where you want to put this pin. The third parameter is a pin description and it is optional.

$pinInfo = $bot->pins->repin($pinId, $boardId, 'my repin');

Edit pin

Edit pin by id. You can change pin's description, link or board:

// Change description and link
$bot->pins->edit($pinId, 'new description', 'new link');

// Change board
$bot->pins->edit($pinId, 'new description', 'new link', $newBoardId);

// Change section
$bot->pins->edit($pinId, 'new description', 'new link', $newBoardId, $newSectionId);

If you have Rich Pins enabled, you can change a title of the pin:

$bot->pins->edit($pinId, 'new description', 'new link', $newBoardId, 'new
title');

Move pin to a new board

Move pin to a new board:

// Change board
$bot->pins->moveToBoard($pinId, $newBoardId);

Delete pin

Delete pin by id:

$bot->pins->delete($pinId);

Copy/move pin

Copy/move pins to board. To copy/move one pin, pass it's id as the first argument. Pass an array of ids to copy/move many pins:

$bot->pins->copy($pinId, $boardId);
$bot->pins->move($pinId, $boardId);

Save image on disk

Save image from pin to the disk. Saves original image of the pin to the specified path:

$imagePath = $bot->pins->saveOriginalImage($pinId, $pathForPics);

Delete pin from board

Delete pins from board. To delete one pin, pass it's id as the first argument. Pass an array of ids to delete many pins:

$bot->pins->deleteFromBoard($pinId, $boardId);

Get list of comments

Get list of comments for a specified pin (returns Pagination object):

$comments = $bot->comments->getList($pinId);
foreach($comments as $comment) {
    // ...
}

// retrieve all comments
$commnets = $bot->comments->getList($pinId)->toArray();

Add comment to pin

Write a comment:

$result = $bot->comments->create($pinId, 'your comment'); 
// Result contains info about written comment. For example,
// comment_id if you want to delete it.

Delete comment from pin

Delete a comment:

$bot->comments->delete($pinId, $commentId);

Get pins for source

Get pins from a specific url. For example: https://pinterest.com/source/flickr.com/ will return recent pins from flickr.com (returns Pagination object):

foreach ($bot->pins->fromSource('flickr.com') as $pin) {
    // ...
}

Pins feed

Get user pins feed (returns Pagination object):

foreach ($bot->pins->feed() as $pin) {
    // ...
}

// Only first 20 pins from feed
foreach ($bot->pins->feed(20) as $pin) {
    // ...
}

Activity

Get activity of a pin (returns Pagination object):

foreach ($bot->pins->activity($pinId) as $data) {
    // ...
}

If you don't want to get all activity records, you can pass a limit as the second parameter. Get 5 last activity records:

$activities = $bot->pins->activity($pinId, 5);
// print_r($activities->toArray());

foreach ($activities as $activity) {
    // ...
}

Related pins

Get related pins for current pin (returns Pagination object):

foreach ($bot->pins->related($pinId) as $pin) {
	// ...
}

Get last 10 related pins for current pin:

$relatedPins = $bot->pins->related($pinId, 10);

// print_r($relatedPins->toArray());

foreach ($relatedPins as $pin) {
    // ...
}

Trending pins

Get trending pins for a specific topic from http://pinterest.com/discover page. Uses topic id, that can be received from $bot->topics->explore() method (returns Pagination object):

$trendingTopics = $bot->topics->explore();
$firstTopicId = $trendingTopics[0]['id'];

$pins = $bot->pins->explore($firstTopicId)->toArray();

Visual similar pins

Get visual similar pins (returns Pagination object):

$result = $bot->pins->visualSimilar($pinId)->toArray();

foreach($bot->pins->visualSimilar($pinId) as $similarData) {
    // ...
}

Send pin via message/email

Send pin with message or by email:

// Send pin with message
$bot->pins->sendWithMessage($pinId, 'message', $userId); // To a user
$bot->pins->sendWithMessage($pinId, 'message', [$userId1, $userId2]); // To many users

// Send pin by email
$bot->pins->sendWithEmail($pinId, 'message', '[email protected]'); // One email
$bot->pins->sendWithEmail($pinId, 'message', ['[email protected]', '[email protected]']); // Many

Pin analytics

Get your pin analytics, like numbers of clicks, views and repins (only for business account);

$analytics = $bot->pins->analytics($pinId);

Share pin

Share a link with a pin where a user can leave his or her reaction on this pin:

$link = $bot->pins->share($pinId);

Leave reaction to pin

Leave a reaction when you were given a sharing link with a pin. The link looks like this: http://pin.it/cTwZfG_. When you open it in your browser Pinterest redirects you to the following url https://www.pinterest.de/pin/332703491213209642/sent/?sfo=1&sender=731835145606177283&invite_code=6cb1d66946464b3f9d0084f623c7822b. To react on this link you need to know a pinId (number after pin) and a userId (number after sender), who sent you a link:

// like
$bot->pins->leaveGoodReaction($pinId, $senderId);
// don't like
$bot->pins->leaveBadReaction($pinId, $senderId);

Try pin

Get the pinners who have tied this pin (returns Pagination object):

$pinners = $bot->pins->tried($pinId);
// print_r($pinners->toArray());

foreach ($pinners as $pinner) {
    // ...
}

Try a pin. The third parameter with path to image file is optional. Returns an array with data of the created record:

$tryRecord = $bot->pins->tryIt($pinId, 'comment', 'pathToImage');

Delete your try. You can use an id field from data received when you created a tryIt record:

$tryRecord = $bot->pins->tryIt($pinId, 'comment', 'pathToImage');

// ...

$bot->pins->deleteTryIt($tryRecord['id']);

Edit your try. You can use an id field from data received when you created a tryIt record. You also need a pin id for your try:

$tryRecord = $bot->pins->tryIt($pinId, 'comment', 'pathToImage');

// ...

$bot->pins->editTryIt($tryRecord['pin']['id'], $tryRecord['id'], 'new comment', 'optionalPathToImage');