UrlGet

Summary: A PmWiki extension to replace PmWiki's use of "file_get_contents" with "cURL"
Version: 2026-09-29
Prerequisites: PmWiki pmwiki-2.7.6; PHP 8.5; ExtensionHub
Status: Beta
Maintainer: simon
Licence: GPL3 #
Categories: Extensions
Users: +1 (view / edit)
Discussion: UrlGet-Talk

Questions answered by this extension

I want to use the built in RecipeCheck or Blocklist recipes.

Description

This extension provides a function UrlGet() which uses "cURl" to retrieve the contents of the URL.
The PmWiki variable $UrlGetFunction is set to UrlGet\UrlGet using the PmWiki function SDV() if it is not already set.

Returns the URL contents as a string, or FALSE, the same as "file_get_contents".
Returns error messages in $FmtV['$UrlGetMsg'].

Install as an extension

Usage

Configuration

There is no configuration.

Internationalisations

There are no internationalisations.

Details

  • OK (200) returns TRUE, all other 200 range status responses return FALSE
  • an empty response returns FALSE
  • does NOT follow HTTP redirects (301, 302, 307, 308), returns FALSE
  • all other responses return FALSE
  • this extension is not intended for use with user-supplied input

Change log / Release notes

2026-09-28 better handle connection timeout and slow speeds 2026-09-11 update for PHP 8.5.10, remove curl_close() 2026-04-16 add a test and documentation 2026-04-08 initial version based on internal production code modifying diag.php to enable RecipeCheck

Testing

It has been possible to carry out only limited testing. The extension is in production use on a Windows and a Linux system. A built in test directive exercises one successful read and one read failure.

  • if the extension does not work on Linux from the archive file uncompress it.

For extension developers

Test if the PHP runtime setting allow_url_fopen is enabled

// check if allow_url_fopen is enabled
$allowUrlFopen = ini_get('allow_url_fopen') === 1;
if (!$allowUrlFopen) {
    $retVal .= RECIPENAME . ': The PHP runtime setting "allow_url_fopen" is not enabled.' . BR;
}

See also

User notes +1: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.