Skip to content
This repository has been archived by the owner on Dec 30, 2020. It is now read-only.

Latest commit

 

History

History
255 lines (185 loc) · 5.79 KB

account.md

File metadata and controls

255 lines (185 loc) · 5.79 KB

Account

Login

$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()) {
    // ...
}

Logout

To logout use logout method:

$bot->auth->logout();

Registration

Simple user

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);

Business account

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);

Confirm email

After registration you will receive a confirmation email. You can pass a link from this email to confirmEmail method:

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

Convert to business account

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');

Profile

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);

Change avatar

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);

Profile settings

You can get your current profile settings calling profile method without any params:

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

Username

In result you can find your username, and all your account settings.

Get your current username:

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

User id

Get your current user id:

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

Ban check

Check if your account is banned:

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

Change password

Change you password:

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

Reset password

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'
);

Clear search history

Remove things you’ve recently searched for from search suggestions:

$bot->user->clearSearchHistory();

Deactivate account

Deactivate current account:

$bot->user->deactivate();

Sessions history

Get sessions history:

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

Invitation

To invite someone by email:

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