PHP Class seregazhuk\PinterestBot\Api\CurlHttpClient

Inheritance: implements seregazhuk\PinterestBot\Api\Contracts\HttpClient
Show file Open project: seregazhuk/php-pinterest-bot

Protected Properties

Property Type Description
$cookieJar string Path to cookies file
$cookies seregazhuk\PinterestBot\Helpers\Cookies Cookies container
$cookiesPath string Path to directory to store cookie file
$curl resource Contains the curl instance.
$currentUrl string
$headers array
$options array Custom CURL options for requests.

Public Methods

Method Description
__construct ( Cookies $cookies )
cookie ( $name ) : mixed Get a cookie value by name
cookies ( ) : array Get all cookies
execute ( string $url, string $postString = '', array $headers = [] ) : string Executes curl request.
getCookiesPath ( ) : string
getCurrentUrl ( ) : string
loadCookies ( string $username = '' ) : seregazhuk\PinterestBot\Api\Contracts\HttpClient Load cookies for specified username
removeCookies ( )
setCookiesPath ( string $path ) Set directory to store all cookie files.
setOptions ( array $options ) : seregazhuk\PinterestBot\Api\Contracts\HttpClient Set custom Curl options to override default
useProxy ( string $host, string $port, string $auth = null, string $type = null ) : seregazhuk\PinterestBot\Api\Contracts\HttpClient
useSocksProxy ( string $host, string $port, null $auth = null ) : seregazhuk\PinterestBot\Api\Contracts\HttpClient

Protected Methods

Method Description
callCurl ( ) : mixed
fillCookies ( )
getDefaultHttpOptions ( ) : array
init ( string $url, string $postString, array $headers ) Initializes curl resource with options.
initCookieFile ( string $username ) : string Returns cookie file name by username. If username is empty we use a random cookie name, to be sure we have different cookies in parallel sessions.
initCookieJar ( $username = '' ) Init cookie file for a specified username. If username is empty we use common cookie file for all sessions. If file does not exist it will be created in system temp directory.
makeHttpOptions ( string $postString = '' ) : array Adds necessary curl options for query.

Method Details

__construct() public method

public __construct ( Cookies $cookies )
$cookies seregazhuk\PinterestBot\Helpers\Cookies

callCurl() protected method

protected callCurl ( ) : mixed
return mixed

cookies() public method

Get all cookies
public cookies ( ) : array
return array

execute() public method

Executes curl request.
public execute ( string $url, string $postString = '', array $headers = [] ) : string
$url string
$postString string
$headers array
return string

fillCookies() protected method

protected fillCookies ( )

getCookiesPath() public method

public getCookiesPath ( ) : string
return string

getCurrentUrl() public method

public getCurrentUrl ( ) : string
return string

getDefaultHttpOptions() protected method

protected getDefaultHttpOptions ( ) : array
return array

init() protected method

Initializes curl resource with options.
protected init ( string $url, string $postString, array $headers )
$url string
$postString string
$headers array

initCookieFile() protected method

Returns cookie file name by username. If username is empty we use a random cookie name, to be sure we have different cookies in parallel sessions.
protected initCookieFile ( string $username ) : string
$username string
return string

initCookieJar() protected method

Init cookie file for a specified username. If username is empty we use common cookie file for all sessions. If file does not exist it will be created in system temp directory.
protected initCookieJar ( $username = '' )
$username

loadCookies() public method

Load cookies for specified username
public loadCookies ( string $username = '' ) : seregazhuk\PinterestBot\Api\Contracts\HttpClient
$username string
return seregazhuk\PinterestBot\Api\Contracts\HttpClient

makeHttpOptions() protected method

Adds necessary curl options for query.
protected makeHttpOptions ( string $postString = '' ) : array
$postString string POST query string
return array

removeCookies() public method

public removeCookies ( )

setCookiesPath() public method

Set directory to store all cookie files.
public setCookiesPath ( string $path )
$path string

setOptions() public method

Set custom Curl options to override default
public setOptions ( array $options ) : seregazhuk\PinterestBot\Api\Contracts\HttpClient
$options array
return seregazhuk\PinterestBot\Api\Contracts\HttpClient

useProxy() public method

public useProxy ( string $host, string $port, string $auth = null, string $type = null ) : seregazhuk\PinterestBot\Api\Contracts\HttpClient
$host string '192.168.1.1'
$port string '12345'
$auth string Authentication string: 'username:password'
$type string HTTP|SOCKS
return seregazhuk\PinterestBot\Api\Contracts\HttpClient

useSocksProxy() public method

public useSocksProxy ( string $host, string $port, null $auth = null ) : seregazhuk\PinterestBot\Api\Contracts\HttpClient
$host string
$port string
$auth null
return seregazhuk\PinterestBot\Api\Contracts\HttpClient

Property Details

$cookieJar protected property

Path to cookies file
protected string $cookieJar
return string

$cookies protected property

Cookies container
protected Cookies,seregazhuk\PinterestBot\Helpers $cookies
return seregazhuk\PinterestBot\Helpers\Cookies

$cookiesPath protected property

Path to directory to store cookie file
protected string $cookiesPath
return string

$curl protected property

Contains the curl instance.
protected resource $curl
return resource

$currentUrl protected property

protected string $currentUrl
return string

$headers protected property

protected array $headers
return array

$options protected property

Custom CURL options for requests.
protected array $options
return array