条目数量 : 403


Guzzle

来自笔记本
跳到导航 跳到搜索

https://guzzle-cn.readthedocs.io/zh_CN/latest/quickstart.html

 $response = $guzzle->request('GET', $url);

    $type = $response->getHeader('content-type');
    $parsed = Psr7\parse_header($type);

    $original_body = (string)$response->getBody();
    $utf8_body = mb_convert_encoding($original_body, 'UTF-8', $parsed[0]['charset'] ?: 'UTF-8');

https://blog.cooooler.com/2018/08/30/%E4%BD%BF%E7%94%A8curl%E8%8E%B7%E5%8F%96%E6%95%B0%E6%8D%AE%E6%97%B6%E7%9A%84%E7%BC%96%E7%A0%81%E9%97%AE%E9%A2%98/