Skip to content

rl421403/php-pinterest-bot

 
 

Repository files navigation

Pinterest Bot for PHP

Build Status Circle CI Code Climate Scrutinizer Code Quality Test Coverage Total Downloads

This PHP class will help you to work with your Pinterest account. You don't need to register application in Pintererst to get access token for api. Use only your account login and password.

Some functions use pinterest navigation through results, for example, get user followers. Function returns generator object with api results as batches in every iteration. By default functions return all pinterest result batches, but you can pass batches num as second argument. For example,

$bot->pins->search('query', 2)

will return only 2 batches of search results.

Dependencies

API requires CURL extension and PHP 5.5 or above.

Installation

Via composer:

php composer.phar require "seregazhuk/pinterest-bot:*"

Quick Start

use seregazhuk\PinterestBot\PinterestBot;

// pass useragent string to request object
$bot = new PinterestBot('mypinterestlogin', 'mypinterestpassword');
$bot->login();

Next, get your list of boards:

$boards = $bot->boards->my();

Pins

Get pin info by its id.

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

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

$pinId = $bot->pins->create('http://exmaple.com/image.jpg', $boards[0]['id'], 'pin description');

Repin other pin by its id.

$bot->pins->repin($pinId, $boards[0]['id'], 'my repin');

Delete pin by id.

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

Like/dislike pin by id.

$bot->pins->like($pinId);
$bot->pins->unLike($pinId);

Write a comment.

$bot->pins->comment($pinId, 'your comment');

Delete a comment.

$bot->pins->deleteComment($pinId, $commentId);

Pinners

Get your account name

$bot->pinners->myAccountName(); 

Follow/unfollow user by ID

$bot->pinners->follow($userId);
$bot->pinners->unfollow($userId);

Get user info by username

$userData = $bot->pinners->info($username);

Get user following. Uses pinterest api pagination.

foreach($bot->pinners->following('username') as $followingBatch)
{
	// ...
}

Get user followers. Uses pinterest api pagination.

foreach($bot->pinners->followers('username') as $followersBatch)
{
	// ...
}

Boards

Follow/unfollow board by ID

$bot->boards->follow($boardId);
$bot->boards->unfollow($boardId);

Interests

Follow/unfollow interest by ID

$bot->interests->follow($interestId);
$bot->interests->unfollow($interestId);

Search

Search functions use pinterest pagination in fetching results and return generator.

foreach($bot->pins->search('query') as $pinsBatch)
{
	// ...
}

foreach($bot->pinners->search('query') as $pinnersBatch)
{
	// ...
}

foreach($bot->pinners->search('query') as $boardsBatch);
{
	// ...
}

About

PHP Pinterest Bot

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%