WsdlToPhp\PackageGenerator\Generator\Utils::getContentFromUrl PHP Method

getContentFromUrl() public static method

Get content from url using a proxy or not
public static getContentFromUrl ( string $url, string $basicAuthLogin = null, string $basicAuthPassword = null, string $proxyHost = null, string $proxyPort = null, string $proxyLogin = null, string $proxyPassword = null, array $contextOptions = [] ) : string
$url string
$basicAuthLogin string
$basicAuthPassword string
$proxyHost string
$proxyPort string
$proxyLogin string
$proxyPassword string
$contextOptions array
return string
    public static function getContentFromUrl($url, $basicAuthLogin = null, $basicAuthPassword = null, $proxyHost = null, $proxyPort = null, $proxyLogin = null, $proxyPassword = null, array $contextOptions = array())
    {
        $context = null;
        $options = self::getContentFromUrlContextOptions($url, $basicAuthLogin, $basicAuthPassword, $proxyHost, $proxyPort, $proxyLogin, $proxyPassword, $contextOptions);
        if (!empty($options)) {
            $context = stream_context_create($options);
        }
        return file_get_contents($url, false, $context);
    }

Usage Example

Example #1
0
 /**
  * @param string $url
  * @return string
  */
 public function getUrlContent($url)
 {
     if (strpos($url, '://') !== false) {
         return Utils::getContentFromUrl($url, $this->getOptionBasicLogin(), $this->getOptionBasicPassword(), $this->getOptionProxyHost(), $this->getOptionProxyPort(), $this->getOptionProxyLogin(), $this->getOptionProxyPassword(), $this->getSoapClient()->getSoapClientStreamContextOptions());
     } elseif (is_file($url)) {
         return file_get_contents($url);
     }
     return null;
 }