Answer the question
In order to leave comments, you need to log in
How to fix file_get_contents(): SSL: Handshake timed out error?
There is this code:
<?php
function simplexml_load_file_from_url($url, $timeout = 20){
$opts = array('http' => array('timeout' => (int)$timeout));
$context = stream_context_create($opts);
$data = file_get_contents($url, false, $context);
if (!$data){
trigger_error('Cannot load data from url: ' . $url, E_USER_NOTICE);
return false;
}
return simplexml_load_string($data);
}
$url = 'https://geocode-maps.yandex.ru/1.x/?geocode=Москва';
$xml = simplexml_load_file_from_url($url);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question