This repository has been archived by the owner on Dec 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 127
/
multiple_accounts_and_proxy.php
81 lines (66 loc) · 1.82 KB
/
multiple_accounts_and_proxy.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
require __DIR__ . '/../vendor/autoload.php';
use seregazhuk\PinterestBot\Factories\PinterestBot;
$accounts = [
[
'login' => 'mylogin1',
'password' => 'mypass1',
'username' => 'cats_account',
'images' => 'images/cats_pics',
'link' => 'http://awasome-blog-about-cats.com',
'proxy' => [
'host' => '123.123.21.21',
'port' => 1234
],
],
[
'login' => 'mylogin2',
'password' => 'mypass2',
'username' => 'dogs_account',
'images' => 'images/dogs_pics',
'link' => 'http://awasome-blog-about-dogs.com',
'proxy' => [
'host' => '123.123.22.22',
'port' => 5678
]
]
];
/**
* @param string $folder
* @return string
*/
function getImage($folder)
{
$images = glob("$folder/*.*");
if (empty($images)) {
echo "No images for posting\n";
die();
}
return $images[0];
}
$bot = PinterestBot::create();
foreach ($accounts as $account) {
// add proxy
if (isset($account['proxy'])) {
$proxy = $account['proxy'];
$bot->getHttpClient()->useProxy($proxy['host'], $proxy['port']);
}
$bot->auth->login($account['login'], $account['password']);
if ($bot->user->isBanned()) {
$username = $account['username'];
die("Account $username has been banned!\n");
}
// get board id
$boards = $bot->boards->forUser($account['username']);
$boardId = $boards[0]['id'];
// select image for posting
$image = getImage($account['images']);
// select keyword
$keywords = $account['keywords'];
$keyword = $keywords[array_rand($keywords)];
// create a pin
$bot->pins->create($image, $boardId, $keyword, $account['link']);
// remove image
unlink($image);
$bot->auth->logout();
}