[ Index ] |
PHP Cross Reference of YOURLS |
[Source view] [Print] [Project Stats]
Functions that relate to HTTP requests On functions using the 3rd party library Requests: Their goal here is to provide convenient wrapper functions to the Requests library. There are 2 types of functions for each METHOD, where METHOD is 'get' or 'post' (implement more as needed) - yourls_http_METHOD() : Return a complete Response object (with ->body, ->headers, ->status_code, etc...) or a simple string (error message) - yourls_http_METHOD_body() : Return a string (response body) or null if there was an error
File Size: | 528 lines (18 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
yourls_http_get( $url, $headers = array() X-Ref |
Perform a GET request, return response object or error string message Notable object properties: body, headers, status_code since: 1.7 return: mixed Response object, or error string param: string $url URL to request param: array $headers HTTP headers to send param: array $data GET data param: array $options Options to pass to Requests |
yourls_http_get_body( $url, $headers = array() X-Ref |
Perform a GET request, return body or null if there was an error since: 1.7 return: mixed String (page body) or null if error param: string $url URL to request param: array $headers HTTP headers to send param: array $data GET data param: array $options Options to pass to Requests |
yourls_http_post( $url, $headers = array() X-Ref |
Perform a POST request, return response object Notable object properties: body, headers, status_code since: 1.7 return: mixed Response object, or error string param: string $url URL to request param: array $headers HTTP headers to send param: array $data POST data param: array $options Options to pass to Requests |
yourls_http_post_body( $url, $headers = array() X-Ref |
Perform a POST request, return body Wrapper for yourls_http_request() since: 1.7 return: mixed String (page body) or null if error param: string $url URL to request param: array $headers HTTP headers to send param: array $data POST data param: array $options Options to pass to Requests |
yourls_http_get_proxy() X-Ref |
Get proxy information since: 1.7.1 return: mixed false if no proxy is defined, or string like '10.0.0.201:3128' or array like ('10.0.0.201:3128', 'username', 'password') |
yourls_http_get_proxy_bypass_host() X-Ref |
Get list of hosts that should bypass the proxy since: 1.7.1 return: mixed false if no host defined, or string like "example.com, *.mycorp.com" |
yourls_http_default_options() X-Ref |
Default HTTP requests options for YOURLS For a list of all available options, see function request() in /includes/Requests/Requests.php since: 1.7 return: array Options |
yourls_send_through_proxy( $url ) X-Ref |
Whether URL should be sent through the proxy server. Concept stolen from WordPress. The idea is to allow some URLs, including localhost and the YOURLS install itself, to be requested directly and bypassing any defined proxy. since: 1.7 return: bool true to request through proxy, false to request directly param: string $url URL to check |
yourls_http_request( $type, $url, $headers, $data, $options ) X-Ref |
Perform a HTTP request, return response object since: 1.7 return: object WpOrg\Requests\Response object param: string $type HTTP request type (GET, POST) param: string $url URL to request param: array $headers Extra headers to send with the request param: array $data Data to send either as a query string for GET requests, or in the body for POST requests param: array $options Options for the request (see /includes/Requests/Requests.php:request()) |
yourls_http_user_agent() X-Ref |
Return funky user agent string since: 1.5 return: string UA string |
yourls_check_core_version() X-Ref |
Check api.yourls.org if there's a newer version of YOURLS This function collects various stats to help us improve YOURLS. See the blog post about it: http://blog.yourls.org/2014/01/on-yourls-1-7-and-api-yourls-org/ Results of requests sent to api.yourls.org are stored in option 'core_version_checks' and is an object with the following properties: - failed_attempts : number of consecutive failed attempts - last_attempt : time() of last attempt - last_result : content retrieved from api.yourls.org during previous check - version_checked : installed YOURLS version that was last checked since: 1.7 return: mixed JSON data if api.yourls.org successfully requested, false otherwise |
yourls_validate_core_version_response($json) X-Ref |
Make sure response from api.yourls.org is valid 1) we should get a json object with two following properties: 'latest' => a string representing a YOURLS version number, eg '1.2.3' 'zipurl' => a string for a zip package URL, from github, eg 'https://api.github.com/repos/YOURLS/YOURLS/zipball/1.2.3' 2) 'latest' and version extracted from 'zipurl' should match 3) the object should not contain any other key since: 1.7.7 return: bool true if seems legit, false otherwise param: object $json JSON object to check |
yourls_get_version_from_zipball_url($zipurl) X-Ref |
Get version number from Github zipball URL (last part of URL, really) since: 1.8.3 return: string param: string $zipurl eg 'https://api.github.com/repos/YOURLS/YOURLS/zipball/1.2.3' |
yourls_is_valid_github_repo_url($url) X-Ref |
Check if URL is from YOURLS/YOURLS repo on github since: 1.8.3 return: bool param: string $url URL to check |
yourls_validate_core_version_response_keys($json) X-Ref |
Check if object has only expected keys 'latest' and 'zipurl' containing strings since: 1.8.3 return: bool param: object $json |
yourls_maybe_check_core_version() X-Ref |
Determine if we want to check for a newer YOURLS version (and check if applicable) Currently checks are performed every 24h and only when someone is visiting an admin page. In the future (1.8?) maybe check with cronjob emulation instead. since: 1.7 return: bool true if a check was needed and successfully performed, false otherwise |
yourls_skip_version_check() X-Ref |
Check if user setting for skipping version check is set since: 1.8.2 return: bool |
yourls_can_http_over_ssl() X-Ref |
Check if server can perform HTTPS requests, return bool since: 1.7.1 return: bool whether the server can perform HTTP requests over SSL |
Generated: Tue Jan 21 05:10:11 2025 | Cross-referenced by PHPXref 0.7.1 |