草庐IT

php - 带有 OAuth 的 Lumen API,Guzzle get/post 方法

我正在构建一个带有OAuth2身份验证的LumenAPI,我遵循了本教程:http://esbenp.github.io/2015/05/26/lumen-web-api-oauth-2-authentication/但我收到一个错误:“fatalerror:第99行C:\Users\user\Desktop\api\lumen\vendor\guzzlehttp\guzzle\src\Handler\CurlMultiHandler.php中超过60秒的最大执行时间”Guzzle的post方法(还有get方法)对我不起作用$app->get('api',function()use($

php - curl 错误 28 : Operation timed out after 2000 milliseconds with 7276200 out of 23000995 bytes received

描述我在Laravel项目中使用Guzzle。当我向返回大量有效负载的API发出请求时,我遇到了内存崩溃。我在CURL.php类的顶部有这个。我有使用Guzzle的get()。useGuzzleHttp\Exception\GuzzleException;useGuzzleHttp\Client;useGuzzleHttp\FORCE_IP_RESOLVE;useGuzzleHttp\DECODE_CONTENT;useGuzzleHttp\CONNECT_TIMEOUT;useGuzzleHttp\READ_TIMEOUT;useGuzzleHttp\TIMEOUT;classCUR

php - 如何向 GuzzleHTTP 请求对象添加身份验证以进行异步处理

我正在创建多个以下GuzzleHttp\Psr7\Requests:useGuzzleHttp\Psr7\Request;$myRequest=newRequest('GET',$someUri);并将它们保存在一个数组中:$guzzleRequests然后我创建一个池来同时执行所有请求:useGuzzleHttp\Pool;$testPool=newPool($testClient=new\GuzzleHttp\Client(),$guzzlePromises,['fulfilled'=>function($response,$index){//thisisdeliveredeach

php - 单元测试 : Simulate a timeout with Guzzle 5

我正在使用Guzzle5.3并想测试我的客户端是否抛出TimeOutException。那么,我如何模拟GuzzleClient并抛出GuzzleHttp\Exception\ConnectException?要测试的代码。publicfunctionrequest($namedRoute,$data=[]){try{/**@noinspectionPhpVoidFunctionResultUsedInspection*//**@var\GuzzleHttp\Message\ResponseInterface$response*/$response=$this->httpClient-

php - 将 cURL 转换为 Guzzle POST

我正在调整一个将图像上传到imgur的示例。该示例使用curl,我使用的是guzzle^6.1。curl的例子是:FormImage(ClientID:50000){exit;}$client_id=$_POST['clientid'];$filetype=explode('/',mime_content_type($_FILES['upload']['tmp_name']));if($filetype[0]!=='image'){die('Invalidimagetype');}$image=file_get_contents($_FILES['upload']['tmp_name'

php - 每当我尝试请求本地主机 :8000/any using guzzle 时,Laravel 服务器就会挂起

如果我向http://localhost:8000或http://127.0.0.1:8000发出任何请求,它会挂起状态挂起。(就像这里的https://github.com/guzzle/guzzle/issues/1857)有人告诉我这与guzzle无关,我最好在这里问一下。我在关注laravel.com/docs/5.4/passport时偶然发现了这个问题这是挂起的代码:$response=$http->post('http://your-app.com/oauth/token',['form_params'=>['grant_type'=>'authorization_cod

php - 如何使用 guzzle 发送具有超时限制的并发请求?

我正在使用Guzzle6发送这样的并发请求:publicfunctionsendConcurrentRequests(){$client=newClient(['timeout'=>5]);$promises[]=$client->getAsync('http://example.com/1');$promises[]=$client->getAsync('http://example.com/2');$promises[]=$client->getAsync('http://example.com/3');$results=Promise\unwrap($promises);retu

php - 找不到类 'Guzzle\Http\Client'

我正尝试在网站点http://www.sitepoint.com/guzzle-php-http-client/上跟进本教程,我这里是一步步安装的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';us

php - Guzzle 检测到 400 或 500 错误时如何防止崩溃?

我正在使用PHPguzzle我试过了publicstaticfunctionget($url){$client=newClient();try{$res=$client->request('GET',$url);$result=(string)$res->getBody();$result=json_decode($result,true);return$result;}catch(GuzzleHttp\Exception\ClientException$e){$response=$e->getResponse();$responseBodyAsString=$response->ge

php - Symfony 无法识别通过 Guzzle 多部分/表单数据请求上传的多个文件

环境:Guzzle6交响乐2.3通过GuzzlePOST请求上传多个文件shouldbedonewithamultipartrequest.所以我像这样配置我的$options数组:Array([multipart]=>Array([0]=>Array([name]=>filename-0[contents]=>Resourceid#440[filename]=>filename-0)[1]=>Array([name]=>filename-1[contents]=>Resourceid#441[filename]=>filename-1)[2]=>Array([name]=>filen