PHP code example of kaankilic / pinbot

1. Go to this page and download the library: Download kaankilic/pinbot library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kaankilic / pinbot example snippets


'providers' => array(
    ...
    Kaankilic\Pinbot\Providers\PinbotServiceProvider::class,
)

'aliases' => array(
    ...
    'Pinbot'=> Kaankilic\Pinbot\Facades\Pinbot::class,
)
 
use Pinbot;
$Pinterest = Pinbot::create();
$bot->auth->login('mypinterestlogin', 'mypinterestpassword');
$boards = $bot->boards->forMe(); //returns the boards of logged user.

$result = $bot->auth->login('mypinterestlogin', 'mypinterestpassword');

$result = $bot->auth->login('mypinterestlogin', 'mypinterestpassword');

if (!$result) {
    echo $bot->getLastError();
    die();
}

$result = $bot->auth->login('mypinterestlogin', 'mypinterestpassword', false);

if ($bot->auth->isLoggedIn()) {
    // ...
}

$bot->auth->logout();

$bot->auth->register('[email protected]', 'password', 'Name');


use seregazhuk\PinterestBot\Api\Forms\Registration;

$registration = new Registration('[email protected]', 'password', 'name');
$registration
    ->setAge(30)
    ->setCountry('DE')
    ->setMaleGender(); // ->setFemaleGender()

$bot->auth->register($registration);

$bot->auth->registerBusiness('[email protected]', 'password', 'BusinessName');

$bot->auth->registerBusiness('[email protected]', 'password', 'BusinessName', 'http://yoursite.com');

use seregazhuk\PinterestBot\Api\Forms\Registration;

$registration = new Registration('[email protected]', 'password', 'name');
$registration
    ->setAge(30)
    ->setCountry('DE')
    ->setMaleGender()
    ->setSite('http://yoursite.com');

$bot->auth->registerBusiness($registration);

$bot->auth->confirmEmail($linkFromEmail);

$bot->auth->convertToBusiness('businessName');

$bot->auth->convertToBusiness('businessName', 'http://yoursite.com');

$bot->password->sendResetLink('[email protected]');

$bot->password->reset(
    'https://post.pinterest.com/f/a/your-password-reset-params',
    'newPassword'
);

use seregazhuk\PinterestBot\Api\Forms\Profile

$profileForm = (new Profile())
            ->setFirstName('John')
            ->setLastName('Doe')
            ->setAbout('My bio')
            ->setCountry('UK');
$bot->user->profile($profileForm);

use seregazhuk\PinterestBot\Api\Forms\Profile

$profileForm = (new Profile())->setImage($pathToFile);
$bot->user->profile($profileForm);

$profile = $bot->user->profile();
echo $profile['username']; // Prints your username

$username = $bot->user->username();

$userId = $bot->user->id();

if ($bot->user->isBanned() {
    // You have ban
}

$bot->password->change('oldPassword', 'newPassword');

$bot->user->clearSearchHistory();

$bot->user->deactivate();

$history = $bot->user->sessionsHistory();

$bot->user->invite($email);

$boards = $bot->boards->forUser($username);

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

$info = $bot->boards->info($username, $board);

// Create a public board
$bot->boards->create('Name', 'Description');

// Create a private board
$bot->boards->createPrivate('Name', 'Description');

$bot->boards->update($boardId, ['name' => 'New title', 'description' => 'New description']);

$bot->boards->update($boardId, [
    'name'        => 'New title',
    'description' => 'New description',
    'privacy'     => 'secret',
    'category'    => 'sports',
]);

$bot->boards->delete($boardId);

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

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

foreach($bot->boards->followers($boardId) as $follower) {
	// ...
}

// Send board with message
$bot->boards->sendWithMessage($boardId, 'Message', $userId); // To a user
$bot->boards->sendWithMessage($boardId, 'Message', [$userId1, $userId2]); // To many yusers

// Send board by email
$bot->boards->sendWithEmail($boardId, 'Message', '[email protected]'); // One email
$bot->boards->sendWithEmail($boardId, 'Message', ['[email protected]', '[email protected]']); // many

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

// to a user by email
$bot->boards->sendInvite($boardId, '[email protected]');

// to a user by user id
$bot->boards->sendInvite($boardId, $userId);

// to users by email
$bot->boards->sendInvite($boardId, ['[email protected]', '[email protected]']);
// to users by user id
$bot->boards->sendInvite($boardId, [$user1Id, $user2Id]);

$bot->boards->acceptInvite($boardId);

$bot->boards->ignoreInvite($boardId);

$bot->boards->deleteInvite($boardId, $userId);
// also you can ban a user specifying third argument as true
$bot->boards->deleteInvite($boardId, $userId, true);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

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

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

// 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

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

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

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

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

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

// ...

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

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

// ...

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

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

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

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

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

foreach ($bot->pinners->following('username', 'people') as $user) {
    // Loop through people
}

foreach($bot->pinners->following('username', 'boards') as $board) {
    // Loop through boards
}

foreach($bot->pinners->following('username', 'interests') as $interest) {
    // Loop through interests
}

foreach ($bot->pinners->followingPeople('username') as $user) {
    // Loop through people
}

foreach ($bot->pinners->followingBoards('username') as $board) {
    // Loop through boards
}

foreach($bot->pinners->followingInterests('username') as $interest) {
    // Loop through interests
}

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

// returns my followers
foreach($bot->pinners->followers() as $follower)
{
	// ...
}

foreach ($bot->pinners->pins('username') as $pin) {
    // ...
}

foreach ($bot->pinners->pins('username', 20) as $pin) {
    // ...
}

foreach ($bot->pinners->likes('username') as $like) {
    // ...
}

// By name
$bot->pinners->block('username');

// By id. For example, after calling info() method
$pinnerInfo = $bot->pinners->info('username');
$bot->pinners->block($pinnerInfo['id']);

$categories = $bot->interests->main();

$info = $bot->interests->info("gifts");

$topics = $bot->interests->getRelatedTopics('videos');

foreach ($bot->interests->pins('videos') as $pin) {
    // ...
}

$bot->topics->follow('content-marketing');
$bot->topics->unFollow('content-marketing');

$info = $bot->topics->info('content-marketing');

foreach ($bot->topics->pins('content-marketing') as $pin) {
    // ...
}

$topics = $bot->topics->getRelatedTopics('content-marketing');


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

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

$pins = $bot->pins->search('query')->toArray();
print_r($pins);

// Or iterate with requests
foreach ($bot->pins->search('query') as $pin) {
    // ...
}

// Search only in my pins
$pins = $bot->pins->searchInMyPins('query')->toArray();

// Search in people
foreach($bot->pinners->search('query') as $pinner) {
    // ...
}

// Search in boards
foreach($bot->boards->search('query') as $board) {
    // ...
}

// Get result as array
$news = $bot->inbox->news()->toArray();

// Iterate with requests
foreach ($bot->inbox->news() as $new) {
    // ...
}

// Get result as array
$notifications = $bot->inbox->notifications()->toArray();

// Iterate with requests
foreach ($bot->inbox->notifications() as $notification) {
    // ...
}

$conversations = $bot->inbox->conversations();
print_r($conversations);

$bot->inbox->sendMessage($userId, 'message text');

$pinId = 123456789;
$bot->inbox->sendMessage($userId, 'message text', $pinId);

$bot->inbox->sendEmail('[email protected]', 'message text');

$bot->inbox->sendEmail('[email protected]', 'message text', $pindId);

$requests = $bot->inbox->contactRequests();
php
$bot->inbox->acceptContactRequest($requestId);
php
$bot->inbox->ignoreContactRequest($requestId);
php
$error = $bot->getLastError();
echo $error;
php
$bot->getHttpClient()->useProxy('192.168.1.1', '12345');
php
$bot->getHttpClient()->useProxy('192.168.1.1', '12345', 'username:password');
php
$bot->getHttpClient()->useSocksProxy('192.168.1.1', '12345');

// With authentication
$bot->getHttpClient()->useSocksProxy('192.168.1.1', '12345', 'username:password');
php
$bot->getHttpClient()->dontUseProxy();
php
if($bot->getHttpClient()->usesProxy()) {
    // ...
}
php
$bot->getHttpClient()->setOptions([
    CURLOPT_PROXY => 'xx.xx.xxx.xx:xxxx',
    CURLOPT_PROXYTYPE => CURLPROXY_HTTP // Or CURLPROXY_SOCKS5,
    CURLOPT_USERAGENT => 'Your_User_Agent',
]);
php
$info = $bot->getClientInfo();
php
// Force to reload client info
$info = $bot->getClientInfo(true);
php
$url = $bot->getHttpClient()->getCurrentUrl();
php
$cookies = $bot->getHttpClient()->cookies();
php
$someCookieValue = $bot->getHttpClient()->cookie('cookieName');
php
$bot->getHttpClient()->setCookiesPath($yourCustomPathForCookies);

$currentPath = $bot->getHttpClient()->getCookiesPath();
php
$bot->getHttpClient()->removeCookies();
php
$pagination = $bot->pins->search('query');

foreach ($pagination as $pin) {
    // ...
}
 
php
$pagination = $bot->pins->search('query');

$results = $pagination->toArray();
// Or
$results = $bot->pins->search('query')->toArray();
php
foreach ($bot->pins->search('query', 20) as $pin) {
    // ...
}