Documentation

Internet
in package

Table of Contents

$ip  : string|false
$online  : bool
getInternalIP()  : string
Returns the machine's internal network IP address. If the machine is not behind a router, this may be the same as the external IP.
getIP()  : string|false
Gets the External IP using an external service, it is cached
getURL()  : InternetRequestResult|null
GETs an URL using cURL NOTE: This is a blocking operation and can take a significant amount of time. It is inadvisable to use this method on the main thread.
postURL()  : InternetRequestResult|null
POSTs data to an URL NOTE: This is a blocking operation and can take a significant amount of time. It is inadvisable to use this method on the main thread.
simpleCurl()  : InternetRequestResult
General cURL shorthand function.

Properties

$ip

public static string|false $ip = false

$online

public static bool $online = true

Methods

getInternalIP()

Returns the machine's internal network IP address. If the machine is not behind a router, this may be the same as the external IP.

public static getInternalIP() : string
Tags
throws
InternetException
Return values
string

getIP()

Gets the External IP using an external service, it is cached

public static getIP([bool $force = false ]) : string|false
Parameters
$force : bool = false

default false, force IP check even when cached

Return values
string|false

getURL()

GETs an URL using cURL NOTE: This is a blocking operation and can take a significant amount of time. It is inadvisable to use this method on the main thread.

public static getURL(string $page[, int $timeout = 10 ][, array<string|int, string> $extraHeaders = [] ][, string|null &$err = null ]) : InternetRequestResult|null
Parameters
$page : string
$timeout : int = 10

default 10

$extraHeaders : array<string|int, string> = []
$err : string|null = null

reference parameter, will be set to the output of curl_error(). Use this to retrieve errors that occured during the operation.

Tags
phpstan-param

list $extraHeaders

Return values
InternetRequestResult|null

postURL()

POSTs data to an URL NOTE: This is a blocking operation and can take a significant amount of time. It is inadvisable to use this method on the main thread.

public static postURL(string $page, array<string|int, string>|string $args[, int $timeout = 10 ][, array<string|int, string> $extraHeaders = [] ][, string|null &$err = null ]) : InternetRequestResult|null
Parameters
$page : string
$args : array<string|int, string>|string
$timeout : int = 10
$extraHeaders : array<string|int, string> = []
$err : string|null = null

reference parameter, will be set to the output of curl_error(). Use this to retrieve errors that occured during the operation.

Tags
phpstan-param

string|array<string, string> $args

phpstan-param

list $extraHeaders

Return values
InternetRequestResult|null

simpleCurl()

General cURL shorthand function.

public static simpleCurl(string $page[, float|int $timeout = 10 ][, array<string|int, string> $extraHeaders = [] ][, array<string|int, mixed> $extraOpts = [] ][, Closure|null $onSuccess = null ]) : InternetRequestResult

NOTE: This is a blocking operation and can take a significant amount of time. It is inadvisable to use this method on the main thread.

Parameters
$page : string
$timeout : float|int = 10

The maximum connect timeout and timeout in seconds, correct to ms.

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

extra headers to send as a plain string array

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

extra CURLOPT_* to set as an [opt => value] map

$onSuccess : Closure|null = null

function to be called if there is no error. Accepts a resource argument as the cURL handle.

Tags
phpstan-param

array<int, mixed> $extraOpts

phpstan-param

list $extraHeaders

phpstan-param

(\Closure(\CurlHandle) : void)|null $onSuccess

throws
InternetException

if a cURL error occurs

Return values
InternetRequestResult

Search results