56 lines
1.7 KiB
PHP
56 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace IriksIT\Manager\Contracts;
|
|
|
|
use IriksIT\Manager\Models\SocialConnection;
|
|
use IriksIT\Manager\Support\Sharing\ShareContent;
|
|
use IriksIT\Manager\Support\Sharing\SharedPost;
|
|
use IriksIT\Manager\Support\Sharing\SharingException;
|
|
|
|
/**
|
|
* Connecting with one platform (a social network) and posting on it. A site adds its own platform by implementing this and
|
|
* listing the class in `manager.sharing.platforms`.
|
|
*/
|
|
interface Sharer
|
|
{
|
|
/** The name the owner reads, for example `LinkedIn`. */
|
|
public function label(): string;
|
|
|
|
/**
|
|
* The longest text the platform takes for the words of a post.
|
|
*/
|
|
public function maxLength(): int;
|
|
|
|
/** The app of the platform is set up (its id and secret are known). */
|
|
public function canConnect(): bool;
|
|
|
|
/** What is missing to connect, for the owner: the labels of the settings to fill in. */
|
|
public function missing(): string;
|
|
|
|
public function connection(): ?SocialConnection;
|
|
|
|
/** The name of the account the site posts as, for the manager. */
|
|
public function accountName(): ?string;
|
|
|
|
/**
|
|
* @param string $verifier a secret of this one attempt (PKCE); a platform that does not use it ignores it
|
|
*/
|
|
public function authorizationUrl(string $state, string $redirectUri, string $verifier): string;
|
|
|
|
/**
|
|
* Trades the code the platform sent back for a token and stores the connection.
|
|
*
|
|
* @throws SharingException
|
|
*/
|
|
public function connect(string $code, string $redirectUri, string $verifier): SocialConnection;
|
|
|
|
public function disconnect(): void;
|
|
|
|
/**
|
|
* Posts for real.
|
|
*
|
|
* @throws SharingException
|
|
*/
|
|
public function publish(ShareContent $content): SharedPost;
|
|
}
|