PHP Class seregazhuk\PinterestBot\Api\Request

Inheritance: implements seregazhuk\PinterestBot\Interfaces\RequestInterface
Afficher le fichier Open project: seregazhuk/php-pinterest-bot Class Usage Examples

Protected Properties

Свойство Type Description
$csrfToken string
$filePathToUpload string
$httpClient seregazhuk\PinterestBot\Api\Contracts\HttpClient
$lastError array | null
$loggedIn boolean
$postFileData string
$requestHeaders array Common headers needed for every query.

Méthodes publiques

Méthode Description
__construct ( seregazhuk\PinterestBot\Api\Contracts\HttpClient $http )
autoLogin ( string $username ) : boolean Load cookies for this username and check if it was logged in.
clearToken ( ) Clear token information.
createQuery ( array $data = [], array $bookmarks = [] ) : string Create request string.
createRequestData ( array $data = [], array $bookmarks = [] ) : array
exec ( string $resourceUrl, string $postString = '' ) : string Executes request to Pinterest API.
getHttpClient ( ) : seregazhuk\PinterestBot\Api\Contracts\HttpClient
getLastError ( ) : array | null
isLoggedIn ( ) : boolean Get current auth status.
login ( ) Mark client as logged.
logout ( ) Mark client as logged out.
setTokenFromCookies ( ) Trying to get csrf token from cookies.
upload ( string $pathToFile, string $url ) : string

Méthodes protégées

Méthode Description
buildFilePostData ( string $delimiter )
getContentTypeHeader ( ) : array If we are uploading file, we should build boundary form data. Otherwise it is simple urlencoded form.
getDefaultHttpHeaders ( ) : array
getHttpHeaders ( ) : array
makeHeadersForUpload ( ) : array

Method Details

__construct() public méthode

public __construct ( seregazhuk\PinterestBot\Api\Contracts\HttpClient $http )
$http seregazhuk\PinterestBot\Api\Contracts\HttpClient

autoLogin() public méthode

Load cookies for this username and check if it was logged in.
public autoLogin ( string $username ) : boolean
$username string
Résultat boolean

buildFilePostData() protected méthode

protected buildFilePostData ( string $delimiter )
$delimiter string

clearToken() public méthode

Clear token information.
public clearToken ( )

createQuery() public static méthode

Create request string.
public static createQuery ( array $data = [], array $bookmarks = [] ) : string
$data array
$bookmarks array
Résultat string

createRequestData() public static méthode

public static createRequestData ( array $data = [], array $bookmarks = [] ) : array
$data array
$bookmarks array
Résultat array

exec() public méthode

Executes request to Pinterest API.
public exec ( string $resourceUrl, string $postString = '' ) : string
$resourceUrl string
$postString string
Résultat string

getContentTypeHeader() protected méthode

If we are uploading file, we should build boundary form data. Otherwise it is simple urlencoded form.
protected getContentTypeHeader ( ) : array
Résultat array

getDefaultHttpHeaders() protected méthode

protected getDefaultHttpHeaders ( ) : array
Résultat array

getHttpClient() public méthode

public getHttpClient ( ) : seregazhuk\PinterestBot\Api\Contracts\HttpClient
Résultat seregazhuk\PinterestBot\Api\Contracts\HttpClient

getHttpHeaders() protected méthode

protected getHttpHeaders ( ) : array
Résultat array

getLastError() public méthode

public getLastError ( ) : array | null
Résultat array | null

isLoggedIn() public méthode

Get current auth status.
public isLoggedIn ( ) : boolean
Résultat boolean

login() public méthode

Mark client as logged.
public login ( )

logout() public méthode

Mark client as logged out.
public logout ( )

makeHeadersForUpload() protected méthode

protected makeHeadersForUpload ( ) : array
Résultat array

setTokenFromCookies() public méthode

Trying to get csrf token from cookies.
public setTokenFromCookies ( )

upload() public méthode

public upload ( string $pathToFile, string $url ) : string
$pathToFile string
$url string
Résultat string

Property Details

$csrfToken protected_oe property

protected string $csrfToken
Résultat string

$filePathToUpload protected_oe property

protected string $filePathToUpload
Résultat string

$httpClient protected_oe property

protected HttpClient,seregazhuk\PinterestBot\Api\Contracts $httpClient
Résultat seregazhuk\PinterestBot\Api\Contracts\HttpClient

$lastError protected_oe property

protected array|null $lastError
Résultat array | null

$loggedIn protected_oe property

protected bool $loggedIn
Résultat boolean

$postFileData protected_oe property

protected string $postFileData
Résultat string

$requestHeaders protected_oe property

Common headers needed for every query.
protected array $requestHeaders
Résultat array