PHP Class seregazhuk\PinterestBot\Api\Request

Inheritance: implements seregazhuk\PinterestBot\Interfaces\RequestInterface
显示文件 Open project: seregazhuk/php-pinterest-bot Class Usage Examples

Protected Properties

Property 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.

Public Methods

Method 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

Protected Methods

Method 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 method

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

autoLogin() public method

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

buildFilePostData() protected method

protected buildFilePostData ( string $delimiter )
$delimiter string

clearToken() public method

Clear token information.
public clearToken ( )

createQuery() public static method

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

createRequestData() public static method

public static createRequestData ( array $data = [], array $bookmarks = [] ) : array
$data array
$bookmarks array
return array

exec() public method

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

getContentTypeHeader() protected method

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

getDefaultHttpHeaders() protected method

protected getDefaultHttpHeaders ( ) : array
return array

getHttpClient() public method

public getHttpClient ( ) : seregazhuk\PinterestBot\Api\Contracts\HttpClient
return seregazhuk\PinterestBot\Api\Contracts\HttpClient

getHttpHeaders() protected method

protected getHttpHeaders ( ) : array
return array

getLastError() public method

public getLastError ( ) : array | null
return array | null

isLoggedIn() public method

Get current auth status.
public isLoggedIn ( ) : boolean
return boolean

login() public method

Mark client as logged.
public login ( )

logout() public method

Mark client as logged out.
public logout ( )

makeHeadersForUpload() protected method

protected makeHeadersForUpload ( ) : array
return array

setTokenFromCookies() public method

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

upload() public method

public upload ( string $pathToFile, string $url ) : string
$pathToFile string
$url string
return string

Property Details

$csrfToken protected_oe property

protected string $csrfToken
return string

$filePathToUpload protected_oe property

protected string $filePathToUpload
return string

$httpClient protected_oe property

protected HttpClient,seregazhuk\PinterestBot\Api\Contracts $httpClient
return seregazhuk\PinterestBot\Api\Contracts\HttpClient

$lastError protected_oe property

protected array|null $lastError
return array | null

$loggedIn protected_oe property

protected bool $loggedIn
return boolean

$postFileData protected_oe property

protected string $postFileData
return string

$requestHeaders protected_oe property

Common headers needed for every query.
protected array $requestHeaders
return array