PHP 클래스 RollingCurl\RollingCurl

파일 보기 프로젝트 열기: chuyskywalker/rolling-curl 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$multicurlOptions array Set your default multicurl options
$options array Set your base options that you want to be used with EVERY request. (Can be overridden individually)

공개 메소드들

메소드 설명
add ( RollingCurl\Request $request ) : RollingCurl Add a request to the request queue
addMulticurlOptions ( array $multicurlOptions ) : RollingCurl Override and add multicurlOptions
addOptions ( array $options ) : RollingCurl Override and add options
clearCompleted ( ) : RollingCurl Clear out all completed requests
countActive ( ) : integer
countCompleted ( boolean $useArray = false ) : integer
countPending ( ) : integer
delete ( string $url, array $headers = null, array $options = null ) : RollingCurl Perform DELETE request
execute ( ) : void Run all queued requests
get ( string $url, array $headers = null, array $options = null ) : RollingCurl Perform GET request
getCallback ( ) : callable
getCompletedRequests ( ) : RollingCurl\Request[]
getHeaders ( ) : array
getIdleCallback ( ) : callable
getMulticurlOptions ( ) : array
getOptions ( ) : array
getSimultaneousLimit ( ) : integer
post ( string $url, array | string $postData = null, array $headers = null, array $options = null ) : RollingCurl Perform POST request
prunePendingRequestQueue ( ) : RollingCurl Removes requests from the queue that have already been processed
put ( string $url, null $putData = null, array $headers = null, array $options = null ) : RollingCurl Perform PUT request
request ( string $url, string $method = "GET", array | string $postData = null, array $headers = null, array $options = null ) : RollingCurl Create new Request and add it to the request queue
setCallback ( callable $callback ) : RollingCurl Define a callable to handle the response.
setHeaders ( array $headers ) : RollingCurl
setIdleCallback ( callable $callback ) : RollingCurl Define a callable to be called when waiting for responses.
setMulticurlOptions ( array $multicurlOptions ) : RollingCurl
setOptions ( array $options ) : RollingCurl
setSimultaneousLimit ( integer $count ) : RollingCurl Set the limit for how many cURL requests will be execute simultaneously.

비공개 메소드들

메소드 설명
getNextPendingRequest ( ) : null | RollingCurl\Request Get the next pending request, or return null
getNextPendingRequests ( integer $limit = 1 ) : RollingCurl\Request[] Return the next $limit pending requests (may return an empty array)
prepareRequestOptions ( RollingCurl\Request $request ) : array Helper function to gather all the curl options: global, inferred, and per request

메소드 상세

add() 공개 메소드

Add a request to the request queue
public add ( RollingCurl\Request $request ) : RollingCurl
$request RollingCurl\Request
리턴 RollingCurl

addMulticurlOptions() 공개 메소드

Override and add multicurlOptions
public addMulticurlOptions ( array $multicurlOptions ) : RollingCurl
$multicurlOptions array
리턴 RollingCurl

addOptions() 공개 메소드

Override and add options
public addOptions ( array $options ) : RollingCurl
$options array
리턴 RollingCurl

clearCompleted() 공개 메소드

If you are running a very large number of requests, it's a good idea to call this every few completed requests so you don't run out of memory.
public clearCompleted ( ) : RollingCurl
리턴 RollingCurl

countActive() 공개 메소드

public countActive ( ) : integer
리턴 integer

countCompleted() 공개 메소드

public countCompleted ( boolean $useArray = false ) : integer
$useArray boolean count the completedRequests array is true. Otherwise use the global counter.
리턴 integer

countPending() 공개 메소드

public countPending ( ) : integer
리턴 integer

delete() 공개 메소드

Perform DELETE request
public delete ( string $url, array $headers = null, array $options = null ) : RollingCurl
$url string
$headers array
$options array
리턴 RollingCurl

execute() 공개 메소드

Run all queued requests
public execute ( ) : void
리턴 void

get() 공개 메소드

Perform GET request
public get ( string $url, array $headers = null, array $options = null ) : RollingCurl
$url string
$headers array
$options array
리턴 RollingCurl

getCallback() 공개 메소드

public getCallback ( ) : callable
리턴 callable

getCompletedRequests() 공개 메소드

public getCompletedRequests ( ) : RollingCurl\Request[]
리턴 RollingCurl\Request[]

getHeaders() 공개 메소드

public getHeaders ( ) : array
리턴 array

getIdleCallback() 공개 메소드

public getIdleCallback ( ) : callable
리턴 callable

getMulticurlOptions() 공개 메소드

public getMulticurlOptions ( ) : array
리턴 array

getOptions() 공개 메소드

public getOptions ( ) : array
리턴 array

getSimultaneousLimit() 공개 메소드

public getSimultaneousLimit ( ) : integer
리턴 integer

post() 공개 메소드

Perform POST request
public post ( string $url, array | string $postData = null, array $headers = null, array $options = null ) : RollingCurl
$url string
$postData array | string
$headers array
$options array
리턴 RollingCurl

prunePendingRequestQueue() 공개 메소드

Beceause the request queue does not shrink during processing (merely traversed), it is sometimes necessary to prune the queue. This method creates a new array starting at the first un-processed request, replaces the old queue and resets counters.
public prunePendingRequestQueue ( ) : RollingCurl
리턴 RollingCurl

put() 공개 메소드

Perform PUT request
public put ( string $url, null $putData = null, array $headers = null, array $options = null ) : RollingCurl
$url string
$putData null
$headers array
$options array
리턴 RollingCurl

request() 공개 메소드

Create new Request and add it to the request queue
public request ( string $url, string $method = "GET", array | string $postData = null, array $headers = null, array $options = null ) : RollingCurl
$url string
$method string
$postData array | string
$headers array
$options array
리턴 RollingCurl

setCallback() 공개 메소드

It can be an anonymous function: $rc = new RollingCurl(); $rc->setCallback(function($request, $rolling_curl) { process }); Or an existing function: class MyClass { function doCurl() { $rc = new RollingCurl(); $rc->setCallback(array($this, 'callback')); } Cannot be private or protected public function callback($request, $rolling_curl) { process } } The called code should expect two parameters: \RollingCurl\Request $request, \RollingCurl\RollingCurl $rollingCurl $request is original request object, but now with body, headers, response code, etc $rollingCurl is the rolling curl object itself (useful if you want to re/queue a URL)
public setCallback ( callable $callback ) : RollingCurl
$callback callable
리턴 RollingCurl

setHeaders() 공개 메소드

public setHeaders ( array $headers ) : RollingCurl
$headers array
리턴 RollingCurl

setIdleCallback() 공개 메소드

Define a callable to be called when waiting for responses.
public setIdleCallback ( callable $callback ) : RollingCurl
$callback callable
리턴 RollingCurl

setMulticurlOptions() 공개 메소드

public setMulticurlOptions ( array $multicurlOptions ) : RollingCurl
$multicurlOptions array
리턴 RollingCurl

setOptions() 공개 메소드

public setOptions ( array $options ) : RollingCurl
$options array
리턴 RollingCurl

setSimultaneousLimit() 공개 메소드

Please be mindful that if you set this too high, requests are likely to fail more frequently or automated software may perceive you as a DOS attack and automatically block further requests.
public setSimultaneousLimit ( integer $count ) : RollingCurl
$count integer
리턴 RollingCurl

프로퍼티 상세

$multicurlOptions 보호되어 있는 프로퍼티

Set your default multicurl options
protected array $multicurlOptions
리턴 array

$options 보호되어 있는 프로퍼티

Set your base options that you want to be used with EVERY request. (Can be overridden individually)
protected array $options
리턴 array