$result = file_get_contents("http://geocode-maps.yandex.ru/1.x/?geocode=".urlencode("")); $handle = fopen("http://www.example.com/", "rb"); $result = fgets($handle);
try { $http = HttpRequest::get("http://geocode-maps.yandex.ru/1.x/?format=json",array("geocode"=>$city))->acceptJson(); $json = $http->ok() ? json_decode($http->body()) : null; } catch (HttpRequestException $e) { exit($e->getMessage()); }
$http = HttpRequest::post("http://example.com/")->form( array( "param1" => "value", "param2" => "value", "file" => "@/home/vasya/attach.txt" )) ->header(HttpRequest::HEADER_USER_AGENT, "Opera/9.60 (J2ME/MIDP; Opera Mini/4.2.14912/812; U; ru)") ->header(HttpRequest::HEADER_REFERER,"http://google.com");
$http = HttpRequest::put("http://example.com/")->upload("/home/vasja/attach.txt");
print_r(HttpRequest::head("http://example.com")->headers());
$image=fopen('image.jpg','wb'); $loaded=HttpRequest::get("http://example.com/file.jpg")->receive($image)->ok(); // boolean
Source: https://habr.com/ru/post/187164/
All Articles