$result = $bot->auth->login('mypinterestlogin', 'mypinterestpassword');
Login method returns true
on success and false
if fails:
$result = $bot->auth->login('mypinterestlogin', 'mypinterestpassword');
if (!$result) {
echo $bot->getLastError();
die();
}
By default bot uses auto-login. It uses cookies, saved from the last session. If auto-login fails, then bot will send login requests.
To skip auto-login and force login requests, you can pass false
as the third argument:
$result = $bot->auth->login('mypinterestlogin', 'mypinterestpassword', false);
Or you may skip login if you want. It is only required for such operations as likes, follows and making pins. You can get your current logged in status via isLoggedIn method:
if ($bot->auth->isLoggedIn()) {
// ...
}
To logout use logout method:
$bot->auth->logout();
To register a new user:
$bot->auth->register('[email protected]', 'password', 'Name');
Use Registration
form object with fluent interface for specifying additional parameters:
use seregazhuk\PinterestBot\Api\Forms\Registration;
$registration = new Registration('[email protected]', 'password', 'name');
$registration
->setAge(30)
->setCountry('DE')
->setMaleGender(); // ->setFemaleGender()
$bot->auth->register($registration);
Register a business account. The last parameter with website url is optional:
$bot->auth->registerBusiness('[email protected]', 'password', 'BusinessName');
$bot->auth->registerBusiness('[email protected]', 'password', 'BusinessName', 'http://yoursite.com');
Variant with Registration form:
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);
After registration you will receive a confirmation email. You can pass a link from this email to confirmEmail
method:
$bot->auth->confirmEmail($linkFromEmail);
Convert your account to a business one. Requires log in. The last parameter with website url is optional:
$bot->auth->convertToBusiness('businessName');
$bot->auth->convertToBusiness('businessName', 'http://yoursite.com');
Change profile. To update profile you need to setup Profile
form object. It has following methods:
setLastName($lastName)
,setFirstName($firstName)
,setUserName($username)
,setAbout($bio)
,setLocation($location)
,setWebsiteUrl($url)
,setCountry($code)
(ISO2 code). list of countries can be retrieved with$bot->user->getCountries()
method,excludeFromSearch($bool)
to exclude your account from search results,setLocale($locale)
, list of locales can be retrieved with$bot->user->getLocales()
method,setAccountType($type)
(only for business account) list of available types can be retrieved with$bot->user->getAccountTypes()
method,setImage($pathToImage)
:
use seregazhuk\PinterestBot\Api\Forms\Profile
$profileForm = (new Profile())
->setFirstName('John')
->setLastName('Doe')
->setAbout('My bio')
->setCountry('UK');
$bot->user->profile($profileForm);
You can change your profile avatar by using setImage()
method and a path to your image:
use seregazhuk\PinterestBot\Api\Forms\Profile
$profileForm = (new Profile())->setImage($pathToFile);
$bot->user->profile($profileForm);
You can get your current profile settings calling profile method without any params:
$profile = $bot->user->profile();
echo $profile['username']; // Prints your username
In result you can find your username, and all your account settings.
Get your current username:
$username = $bot->user->username();
Get your current user id:
$userId = $bot->user->id();
Check if your account is banned:
if ($bot->user->isBanned() {
// You have ban
}
Change you password:
$bot->password->change('oldPassword', 'newPassword');
You can send to your email a link to reset your password:
$bot->password->sendResetLink('[email protected]');
Then your can grab a link from email and pass use it to reset password:
$bot->password->reset(
'https://post.pinterest.com/f/a/your-password-reset-params',
'newPassword'
);
Remove things you’ve recently searched for from search suggestions:
$bot->user->clearSearchHistory();
Deactivate current account:
$bot->user->deactivate();
Get sessions history:
$history = $bot->user->sessionsHistory();
To invite someone by email:
$bot->user->invite($email);