Beispiel #1
0
/**
 * Gets data from a specific URL
 * It will try several methods before fails.
 *
 * @param $url - the URL to get data from
 * @return data if accessible or false if not accessible
 */
function get($url)
{
    // Try to get the url content with file_get_contents()
    $getWithFileContents = getWithFileContents($url);
    if ($getWithFileContents !== false) {
        return trim($getWithFileContents);
    }
    // Try to get the url content with cURL library
    $getWithCURL = getWithCURL($url);
    if ($getWithCURL !== false) {
        return trim($getWithCURL);
    }
    // Default, return false
    return false;
}
Beispiel #2
0
/**
 * Gets data from a specific URL
 * It will try several methods before fails.
 * 
 * First we will see if there is any proxy.ini file set inside [data] folder
 * and then if the proxy is activated.
 * 
 * Then we will try with 
 *
 * @param $url - the URL to get data from
 * @return data if accessible or false if not accessible
 */
function get($url)
{
    $proxyFilePath = getProxyConfigPath();
    $use_proxy = FALSE;
    if (file_exists($proxyFilePath)) {
        //use proxy settings only if proxy.ini is present
        $use_proxy = TRUE;
    }
    // Try to get the url content with file_get_contents()
    $getWithFileContents = getWithFileContents($url, $use_proxy);
    if ($getWithFileContents !== false) {
        return trim($getWithFileContents);
    }
    // Try to get the url content with cURL library
    $getWithCURL = getWithCURL($url);
    if ($getWithCURL !== false) {
        return trim($getWithCURL);
    }
    // Default, return false
    return false;
}