forked from seregazhuk/php-pinterest-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauto_pins.php
37 lines (27 loc) · 824 Bytes
/
auto_pins.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
require __DIR__ . '/../vendor/autoload.php';
use seregazhuk\PinterestBot\Factories\PinterestBot;
$blogUrl = 'http://awasome-blog-about-cats.com';
$keywords = ['cats', 'kittens', 'funny cats', 'cat pictures', 'cats art'];
$bot = PinterestBot::create();
$bot->auth->login('mypinterestlogin', 'mypinterestpassword');
if ($bot->user->isBanned()) {
echo "Account has been banned!\n";
die();
}
// get board id
$boards = $bot->boards->forUser('my_username');
$boardId = $boards[0]['id'];
// select image for posting
$images = glob('images/*.*');
if (empty($images)) {
echo "No images for posting\n";
die();
}
$image = $images[0];
// select keyword
$keyword = $keywords[array_rand($keywords)];
// create a pin
$bot->pins->create($image, $boardId, $keyword, $blogUrl);
// remove image
unlink($image);