vB_Utility_Url
in package
Uses
vB_Utility_Trait_NoSerialize
Table of Contents
Constants
- CLOSECONNECTION = 1024
- COOKIE = 10022
- CUSTOMREQUEST = 16384
- DIEONMAXSIZE = 65536
- ENCODING = 32
- ERROR_MAXSIZE = 1
- ERROR_NOFILE = 2
- ERROR_NOLIB = 8
- FOLLOWLOCATION = 2048
- HEADER = 8
- HTTPHEADER = 256
- MAXREDIRS = 4096
- MAXSIZE = 32768
- NOBODY = 8192
- NOBODY_TYPES = 524288
- POST = 4
- POSTFIELDS = 16
- TEMPFILENAME = 262144
- TIMEOUT = 2
- URL = 1
- USERAGENT = 64
- VALIDSSLONLY = 131072
Methods
- __construct() : mixed
- Constructor
- __destruct() : mixed
- This deals with the case that people forget to either unlink or move the file.
- __serialize() : array<string|int, mixed>
- __sleep() : array<string|int, mixed>
- __unserialize() : void
- __wakeup() : void
- curl_callback_header() : int
- Callback for handling headers
- curl_callback_response() : int
- Callback for handling the request body
- get() : false
- Perform a GET request
- getError() : int
- Return Error
- isSiteUrl() : mixed
- post() : false
- Perform a POST request
- postJson() : false
- Perform a POST request using a JSON post body
- reset() : mixed
- setOption() : mixed
- On/Off options
Constants
CLOSECONNECTION
public
mixed
CLOSECONNECTION
= 1024
COOKIE
public
mixed
COOKIE
= 10022
CUSTOMREQUEST
public
mixed
CUSTOMREQUEST
= 16384
DIEONMAXSIZE
public
mixed
DIEONMAXSIZE
= 65536
ENCODING
public
mixed
ENCODING
= 32
ERROR_MAXSIZE
public
mixed
ERROR_MAXSIZE
= 1
ERROR_NOFILE
public
mixed
ERROR_NOFILE
= 2
ERROR_NOLIB
public
mixed
ERROR_NOLIB
= 8
FOLLOWLOCATION
public
mixed
FOLLOWLOCATION
= 2048
HEADER
public
mixed
HEADER
= 8
HTTPHEADER
public
mixed
HTTPHEADER
= 256
MAXREDIRS
public
mixed
MAXREDIRS
= 4096
MAXSIZE
public
mixed
MAXSIZE
= 32768
NOBODY
public
mixed
NOBODY
= 8192
NOBODY_TYPES
public
mixed
NOBODY_TYPES
= 524288
POST
public
mixed
POST
= 4
POSTFIELDS
public
mixed
POSTFIELDS
= 16
TEMPFILENAME
public
mixed
TEMPFILENAME
= 262144
TIMEOUT
public
mixed
TIMEOUT
= 2
URL
public
mixed
URL
= 1
USERAGENT
public
mixed
USERAGENT
= 64
VALIDSSLONLY
public
mixed
VALIDSSLONLY
= 131072
Methods
__construct()
Constructor
public
__construct(vB_Utility_String $string, int|array<string|int, mixed> $validationOptions) : mixed
Parameters
- $string : vB_Utility_String
-
-- the properly configured string object.
- $validationOptions : int|array<string|int, mixed>
-
-- If not provided this is assumed to be an int value for an additional port. This usage is deprecated. If not provided these options default to empty/false/'' as appropriate. array allowedports -- ports in addition to 80 and 443 that we allow outgoing connections to. bool allowip -- allow IP addresses as host bool allowlocal -- allow localhost bool allowedsiteroot -- skip validation for links back to this site.
__destruct()
This deals with the case that people forget to either unlink or move the file.
public
__destruct() : mixed
__serialize()
public
__serialize() : array<string|int, mixed>
Return values
array<string|int, mixed>__sleep()
public
__sleep() : array<string|int, mixed>
Return values
array<string|int, mixed>__unserialize()
public
__unserialize(mixed $serialized) : void
Parameters
- $serialized : mixed
__wakeup()
public
__wakeup() : void
curl_callback_header()
Callback for handling headers
public
curl_callback_header(mixed $curlHandle, mixed $string) : int
Parameters
- $curlHandle : mixed
- $string : mixed
Return values
int —length of the request
curl_callback_response()
Callback for handling the request body
public
curl_callback_response(mixed $curlHandle, mixed $response) : int
Parameters
- $curlHandle : mixed
- $response : mixed
Return values
int —length of the request
get()
Perform a GET request
public
get(string $url) : false
Parameters
- $url : string
Return values
false —| array -- array headers -- the httpheaders return. Empty if the HEADER is not set -- string body -- the body of the request. Empty if NOBODY is set Returns false on error
getError()
Return Error
public
getError() : int
Return values
int —errorcode
isSiteUrl()
public
isSiteUrl(mixed $urlinfo) : mixed
Parameters
- $urlinfo : mixed
post()
Perform a POST request
public
post(string $url, array<string|int, mixed>|string $postdata) : false
Parameters
- $url : string
- $postdata : array<string|int, mixed>|string
-
-- the data as either an array or "query param" string
Return values
false —| array -- array headers -- the httpheaders return. Empty if the HEADER is not set -- string body -- the body of the request. Empty if NOBODY is set Returns false on error
postJson()
Perform a POST request using a JSON post body
public
postJson(string $url, string $postdata) : false
This performs as post using a custom JSON request (popular with REST APIs) instead of a standard x-www-form-urlencoded format
Parameters
- $url : string
- $postdata : string
-
-- the JSON encoded request.
Return values
false —| array -- array headers -- the httpheaders return. Empty if the HEADER is not set -- string body -- the body of the request. Empty if NOBODY is set Returns false on error
reset()
public
reset() : mixed
setOption()
On/Off options
public
setOption(mixed $option, mixed $extra) : mixed
Parameters
- $option : mixed
- $extra : mixed