Php libcurl alternative

Are there any alternatives to using curl on hosts that have turbulence disabled?

+3
source share
4 answers

To receive content via HTTP, you can first try file_get_contents; Your host may not disable the http: // stream:

$str = file_get_contents('http://www.google.fr');

The bit can be disabled (see allow_url_fopen); and sometimes it ...


If it is disabled, you can try using fsockopen ; the example given in the manual says this (quoting):

$fp = fsockopen("www.example.com", 80, $errno, $errstr, 30);
if (!$fp) {
    echo "$errstr ($errno)<br />\n";
} else {
    $out = "GET / HTTP/1.1\r\n";
    $out .= "Host: www.example.com\r\n";
    $out .= "Connection: Close\r\n\r\n";
    fwrite($fp, $out);
    while (!feof($fp)) {
        echo fgets($fp, 128);
    }
    fclose($fp);
}

Given this rather low level (although you work with a socket, and the HTTP protocol is not so simple), using a library that uses it will make your life easier.

, snoopy; .

+7

curl- script PHP curl, - , , , . , .

+2

, , . , - , , HTTP- - PHP- " " ( ) curl. , , , . , , / , http-.

+2

Source: https://habr.com/ru/post/1716340/


All Articles