[ 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 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 since: 1.7 |
yourls_http_get_body( $url, $headers = array() X-Ref |
Perform a GET request, return body or null if there was an error 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 since: 1.7 |
yourls_http_post( $url, $headers = array() X-Ref |
Perform a POST request, return response object Notable object properties: body, headers, status_code 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 since: 1.7 |
yourls_http_post_body( $url, $headers = array() X-Ref |
Perform a POST request, return body Wrapper for yourls_http_request() 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 since: 1.7 |
yourls_http_get_proxy() X-Ref |
Get proxy information 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') since: 1.7.1 |
yourls_http_get_proxy_bypass_host() X-Ref |
Get list of hosts that should bypass the proxy return: mixed false if no host defined, or string like "example.com, *.mycorp.com" since: 1.7.1 |
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 return: array Options since: 1.7 |
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. return: bool true to request through proxy, false to request directly param: string $url URL to check since: 1.7 |
yourls_http_request( $type, $url, $headers, $data, $options ) X-Ref |
Perform a HTTP request, return response object 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()) since: 1.7 |
yourls_http_user_agent() X-Ref |
Return funky user agent string return: string UA string since: 1.5 |
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 return: mixed JSON data if api.yourls.org successfully requested, false otherwise since: 1.7 |
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 return: bool true if seems legit, false otherwise param: object $json JSON object to check since: 1.7.7 |
yourls_get_version_from_zipball_url($zipurl) X-Ref |
Get version number from Github zipball URL (last part of URL, really) return: string param: string $zipurl eg 'https://api.github.com/repos/YOURLS/YOURLS/zipball/1.2.3' since: 1.8.3 |
yourls_is_valid_github_repo_url($url) X-Ref |
Check if URL is from YOURLS/YOURLS repo on github return: bool param: string $url URL to check since: 1.8.3 |
yourls_validate_core_version_response_keys($json) X-Ref |
Check if object has only expected keys 'latest' and 'zipurl' containing strings return: bool param: object $json since: 1.8.3 |
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. return: bool true if a check was needed and successfully performed, false otherwise since: 1.7 |
yourls_skip_version_check() X-Ref |
Check if user setting for skipping version check is set return: bool since: 1.8.2 |
yourls_can_http_over_ssl() X-Ref |
Check if server can perform HTTPS requests, return bool return: bool whether the server can perform HTTP requests over SSL since: 1.7.1 |
Generated: Sat Feb 22 05:10:06 2025 | Cross-referenced by PHPXref 0.7.1 |