Documentation

FtpFetcher extends WebFetchApi
in package

Fetches data from FTP URLs.

Table of Contents

Properties

$current_redirect  : int
$email  : string
$error_code  : int
$error_message  : string
$host  : string
$port  : int
$response  : array<string|int, mixed>
$scheme_handlers  : array<string|int, mixed>
$user  : string
$still_alive  : array<string|int, mixed>

Methods

__construct()  : mixed
Constructor.
fetch()  : string|false
Get the contents of a URL, irrespective of allow_url_fopen.
request()  : self
Main calling function.
result()  : mixed
Used to return the results to the caller.
resultRaw()  : array<string|int, mixed>
Since this class doesn't support redirects, this method is practically useless, but it's required to comply with FetcherApiInterface.
buildPostData()  : string
Takes supplied POST data and urlencodes it.

Properties

$current_redirect

public int $current_redirect = 0

How many redirects have been followed.

$email

public string $email

The email address to connect with.

$error_code

public int $error_code = 0

Error number that occurred in the system-level connect() call.

$error_message

public string $error_message = ''

The error message as a string.

$host

public string $host

The host we are connecting to.

$port

public int $port

The port we are connecting to.

$response

public array<string|int, mixed> $response = []

Stores responses (url, code, error, headers, body, size).

$scheme_handlers

public static array<string|int, mixed> $scheme_handlers = ['ftp' => ['FtpFetcher'], 'ftps' => ['FtpFetcher'], 'http' => ['SocketFetcher', 'CurlFetcher'], 'https' => ['SocketFetcher', 'CurlFetcher']]

Specifies the fetcher class or classes to try for any given URL scheme.

Keys are URL schemes. Values are the names of one or more classes to try.

Class names will be prepended with NAMESPACE . '\APIs'.

$user

public string $user

The user name to connect with.

$still_alive

private static array<string|int, mixed> $still_alive = []

Fetchers that still have an open connection after the initial request.

Methods

__construct()

Constructor.

public __construct([string $user = null ][, string $email = null ]) : mixed
Parameters
$user : string = null

User name to connect with. If null, uses 'anonymous'.

$email : string = null

Email address to connect with. Defaults to Config::$webmaster_email, or 'nobody@example.com' if that is not set.

fetch()

Get the contents of a URL, irrespective of allow_url_fopen.

public static fetch(Url|string $url[, string|array<string|int, mixed> $post_data = [] ][, bool $keep_alive = false ]) : string|false
  • Reads the contents of an HTTP or FTP address and returns those contents in a string.
  • If $post_data is supplied, the value and length is posted to the given URL as form data.
Parameters
$url : Url|string

An HTTP or FTP URL.

$post_data : string|array<string|int, mixed> = []

The data to post to the given URL. Not applicable to FTP requests.

$keep_alive : bool = false

Whether to keep the connection alive for further requests. Not applicable to FTP requests.

Return values
string|false

The fetched data or false on failure.

request()

Main calling function.

public request(string|Url $url[, array<string|int, mixed>|string $post_data = [] ]) : self
  • Will request the page data from a given $url.
  • Optionally will post data to the page form if $post_data is supplied. Passed arrays will be converted to a POST string joined with &'s.
Parameters
$url : string|Url

the site we are going to fetch

$post_data : array<string|int, mixed>|string = []

any post data as form name => value

Return values
self

A reference to the object for method chaining.

result()

Used to return the results to the caller.

public result([string $area = null ]) : mixed
  • Called as ->result() will return the full final array.
  • Called as ->result('body') to return the page source of the result.
Parameters
$area : string = null

Used to return an area such as body, header, error.

Return values
mixed

The response

resultRaw()

Since this class doesn't support redirects, this method is practically useless, but it's required to comply with FetcherApiInterface.

public resultRaw([int $response_number = null ]) : array<string|int, mixed>
Parameters
$response_number : int = null

Which response to get, or null for all.

Return values
array<string|int, mixed>

The specified response or all the responses.

buildPostData()

Takes supplied POST data and urlencodes it.

protected buildPostData(array<string|int, mixed>|string $post_data) : string
  • Forms the data (for POST) into a string like var=xyz&var2=abc&var3=123
  • Drops vars with @ since we don't support sending files (uploading)
Parameters
$post_data : array<string|int, mixed>|string

The raw POST data.

Return values
string

A string of POST data.


        
On this page

Search results