我正在尝试在 sitepoint 上跟进本教程http://www.sitepoint.com/guzzle-php-http-client/ http://www.sitepoint.com/guzzle-php-http-client/,我这里是一步步安装的http://docs.guzzlephp.org/en/latest/overview.html#installation http://docs.guzzlephp.org/en/latest/overview.html#installation我正在尝试运行第一个简单的示例,但它给了我问题。我还检查了我的 PHP 版本要求(5.5):我的是 5.6,所以没关系。
我使用的是 MAC,请参阅下面的代码。
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once 'vendor/autoload.php';
use Guzzle\Http\Client;
use Guzzle\Http\EntityBody;
use Guzzle\Http\Message\Request;
use Guzzle\Http\Message\Response;
$client = new Client("https://qrng.anu.edu.au");
$request = $client->get('/API/jsonI.php?length=10&type=uint8');
$response = $request->send();
echo $body = $response->getBody(true);
请问,我错过了什么?
It is,
use GuzzleHttp\Client;
看来您的以下教程基于Guzzle 3.7
并且您已经安装了Guzzle 6
.
了解更多。 http://docs.guzzlephp.org/en/latest/quickstart.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)