|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
require __DIR__ . '/../vendor/autoload.php'; |
|
4
|
|
|
|
|
5
|
|
|
use seregazhuk\PinterestBot\Factories\PinterestBot; |
|
6
|
|
|
|
|
7
|
|
|
$accounts = [ |
|
8
|
|
|
[ |
|
9
|
|
|
'login' => 'mylogin1', |
|
10
|
|
|
'password' => 'mypass1', |
|
11
|
|
|
'username' => 'cats_account', |
|
12
|
|
|
'images' => 'images/cats_pics', |
|
13
|
|
|
'link' => 'http://awasome-blog-about-cats.com', |
|
14
|
|
|
'proxy' => [ |
|
15
|
|
|
'host' => '123.123.21.21', |
|
16
|
|
|
'post' => 1234 |
|
17
|
|
|
], |
|
18
|
|
|
], |
|
19
|
|
|
[ |
|
20
|
|
|
'login' => 'mylogin2', |
|
21
|
|
|
'password' => 'mypass2', |
|
22
|
|
|
'username' => 'dogs_account', |
|
23
|
|
|
'images' => 'images/dogs_pics', |
|
24
|
|
|
'link' => 'http://awasome-blog-about-dogs.com', |
|
25
|
|
|
'proxy' => [ |
|
26
|
|
|
'host' => '123.123.22.22', |
|
27
|
|
|
'post' => 5678 |
|
28
|
|
|
] |
|
29
|
|
|
] |
|
30
|
|
|
]; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @param string $folder |
|
34
|
|
|
* @return string |
|
35
|
|
|
*/ |
|
36
|
|
|
function getImage($folder) { |
|
37
|
|
|
|
|
38
|
|
|
$images = glob("$folder/*.*"); |
|
39
|
|
|
if(empty($images)) { |
|
40
|
|
|
echo "No images for posting\n"; |
|
41
|
|
|
die(); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
return $images[0]; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
$bot = PinterestBot::create(); |
|
48
|
|
|
|
|
49
|
|
|
foreach($accounts as $account) { |
|
50
|
|
|
$bot->auth->login($account['login'], $account['password']); |
|
51
|
|
|
|
|
52
|
|
|
// add proxy |
|
53
|
|
|
if(isset($account['proxy'])) { |
|
54
|
|
|
$proxy = $account['proxy']; |
|
55
|
|
|
$bot->getHttpClient()->useProxy($proxy['host'], $proxy['port']); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
if ($bot->user->isBanned()) { |
|
59
|
|
|
$username = $account['username']; |
|
60
|
|
|
die("Account $username has been banned!\n"); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
// get board id |
|
64
|
|
|
$boards = $bot->boards->forUser($account['username']); |
|
65
|
|
|
$boardId = $boards[0]['id']; |
|
66
|
|
|
|
|
67
|
|
|
// select image for posting |
|
68
|
|
|
$image = getImage($account['images']); |
|
69
|
|
|
|
|
70
|
|
|
// select keyword |
|
71
|
|
|
$keywords = $account['keywords']; |
|
72
|
|
|
$keyword = $keywords[array_rand($keywords)]; |
|
73
|
|
|
|
|
74
|
|
|
// create a pin |
|
75
|
|
|
$bot->pins->create($image, $boardId, $keyword, $account['link']); |
|
76
|
|
|
|
|
77
|
|
|
// remove image |
|
78
|
|
|
unlink($image); |
|
79
|
|
|
$bot->auth->logout(); |
|
80
|
|
|
} |
|
81
|
|
|
|