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

Latest commit

 

History

History
127 lines (96 loc) · 3.06 KB

inbox.md

File metadata and controls

127 lines (96 loc) · 3.06 KB

Inbox

News

Get your current user's news (returns Pagination object):

// Get result as array
$news = $bot->inbox->news()->toArray();

// Iterate with requests
foreach ($bot->inbox->news() as $new) {
    // ...
}

Notifications

Get all

Get user's notifications (returns Pagination object):

// Get result as array
$notifications = $bot->inbox->notifications()->toArray();

// Iterate over notifications
foreach ($bot->inbox->notifications() as $notification) {
    // ...
}

Details for notification

Each notification from the method above is represented by array. This array contains id field, which is an id of the current notification (or consider as news id). This id can be used to retrieve details for this notification (returns Pagination object):

// Get details for notification by its id
$details = $bot->inbox->newsHubDetails($notificationId);

// Iterate over details
foreach ($bot->inbox->newsHubDetails($notificationId) as $detail) {
    // ...
}

Conversations

Get a list of last conversations (returns Pagination object):

$conversations = $bot->inbox->conversations();

// Iterate over conversations
foreach($conversations as $conversation) {
    // ...
}

Get messages for a specified conversation (returns Pagination object). Conversation id can be retrieved via $bot->inbox->conversations() method:

$conversations = $bot->inbox->conversations()->toArray();

// Iterate over messages
foreach($bot->inbox->getMessages($conversations[0]['id']) as $message) {
    // ...
}

Write a message

Notice that, when you are sending a message to unknown person Pinterest doesn't show your message. It suggests this person to create a contact with you. Only then you can send messages, see Contact requests

Write a message to a user by id. You may specify one user by id, or pass an array of user ids:

$bot->inbox->sendMessage($userId, 'message text');

Attach pin by id to message:

$pinId = 123456789;
$bot->inbox->sendMessage($userId, 'message text', $pinId);

Send email

Email param may be string or array of emails:

$bot->inbox->sendEmail('mail@domain.com', 'message text');

Attach pin to email:

$bot->inbox->sendEmail('mail@domain.com', 'message text', $pindId);

Contact requests

When someone at first sends you an invitation to a board or a message, you receive a contact request. Get a list of contact requests:

$requests = $bot->inbox->contactRequests();

To accept or to ignore a request you need to specify a request ID. This ID can be received from the array returned in $bot->inbox->contactRequests() method.

Accept a request:

$bot->inbox->acceptContactRequest($requestId);

Ignore a request:

$bot->inbox->ignoreContactRequest($requestId);