Evernote\Client::shareNote PHP Method

shareNote() public method

Shares a note and returns the share url
public shareNote ( Evernote\Model\Note $note ) : null | string
$note Evernote\Model\Note
return null | string
    public function shareNote(Note $note)
    {
        if (null === $note->guid) {
            return null;
        }
        // we have the credentials
        if (null !== $note->noteStore && null !== $note->authToken) {
            $shareKey = $note->noteStore->shareNote($note->authToken, $note->guid);
            $shardId = $this->getShardIdFromToken($note->authToken);
            return $this->getShareUrl($note->guid, $shardId, $shareKey, $this->getAdvancedClient()->getEndpoint());
        }
        try {
            // We don't have credentials so we assume it's a personal note
            return $this->getUserNotestore()->shareNote($this->token, $note->guid);
        } catch (EDAMNotFoundException $e) {
            // The note's not in a personal notebook. We'll need to find it
            $note = $this->getNote($note->guid, self::LINKED_SCOPE);
            if (null !== $note) {
                $shareKey = $note->noteStore->shareNote($note->authToken, $note->guid);
                $shardId = $this->getShardIdFromToken($note->authToken);
                return $this->getShareUrl($note->guid, $shardId, $shareKey, $this->getAdvancedClient()->getEndpoint());
            }
            return null;
        }
    }