jjzjj

php - 使用 Guzzle 将更新数据发布到 EventBrite API

我可以通过以下代码使用post添加事件://Createclient$client=newClient(['base_uri'=>'https://www.eventbriteapi.com/v3/',]);$params=['event.name.html'=>$this->Name,'event.description.html'=>$this->Description,'event.listed'=>false,'event.start.utc'=>$this->StartTime,'event.start.timezone'=>'Europe/London','event.en

php - Guzzle 5 - 在 ServerException 上获取响应主体

我正在使用Guzzle(最新的5.2)对服务器进行POST调用。此服务器上的API返回“HTTP/1.1500内部服务器错误”响应,但也返回一个正文。如何访问异常响应的主体?以下是我使用curl-v执行POST时得到的结果:*uploadcompletelysentoff:826outof826bytes9 最佳答案 我发现了一个解决方案:$exception->getResponse()->getBody()本可以发誓我几个小时前就试过了,但没有用,但我想没有。 关于php-Guzzl

php - 异步使用 Guzzle promises

我正在尝试使用guzzlepromises为了进行一些http调用,以说明我所拥有的,我做了这个简单的示例,其中一个假的http请求需要5秒:$then=microtime(true);$promise=newPromise(function()use(&$promise){//Makearequesttoanhttpserver$httpResponse=200;sleep(5);$promise->resolve($httpResponse);});$promise2=newPromise(function()use(&$promise2){//Makearequesttoanht

php - 使用 Guzzle 上传文件

我有一个可以上传视频并将其发送到远程目的地的表格。我有一个cURL请求,我想使用Guzzle将其“翻译”为PHP。到目前为止我有这个:publicfunctionupload(Request$request){$file=$request->file('file');$fileName=$file->getClientOriginalName();$realPath=$file->getRealPath();$client=newClient();$response=$client->request('POST','http://mydomain.de:8080/spots',['mu

PHPUnit 和来自 Guzzle 的模拟请求

我有一个具有以下功能的类:publicfunctionget(string$uri):stdClass{$this->client=newClient;$response=$this->client->request('GET',$uri,$this->headers);returnjson_decode($response->getBody());}如何从PHPUnit模拟请求方法?我尝试了不同的方法,但它总是尝试连接到指定的uri。我试过:$clientMock=$this->getMockBuilder('GuzzleHttp\Client')->setMethods('requ

php - 使用 GuzzleHttp 从 HTTP 调用中获取 cookie 的值

我现在使用GuzzleHttp发出HTTP请求,首先我向login.asp发出POST请求,它返回带有Set-Cookie的响应,其中包含我future请求所需的值当我检查我获得的答案时,我得到以下信息如前所述,我得到了除Set-Cookie之外的所有key,这会发生什么?我怎样才能得到这个值?我正在使用"guzzlehttp/guzzle":"^6.3",或者我可以使用其他工具获取它吗?$jar=newCookieJar;$client=newClient(['base_uri'=>'miurl/','timeout'=>10.0,'cookies'=>$jar]);$respons

php - 本地 WordPress 站点上的 cURL 返回 : Error 6 (Could not resolve host)

我有一个本地WordPress安装运行在:https://catalogue3.test.请注意,所有.test域都应解析为localhost,因为我使用Laravelvalet.但是,当我在我的Laravel项目中执行以下代码时,出现如下所示的异常。$client=new\GuzzleHttp\Client();$response=$client->request('GET',"https://catalogue3.test",['verify'=>false]);ConnectExceptioncURLerror6:Couldnotresolve:catalogue3.test(D

php - 没有 Composer 的狂欢

我需要使用sproutvideo需要Guzzle的php库Guzzle需要安装composer但不确定是否需要运行,因为我在某些文件中找到了require'vendor/autoload.php';我从未使用过composer,我在共享主机上,我无法安装它我从github下载Guzzle但不确定我是否解决了autoload.php工作人员以及是否要工作 最佳答案 您不应该选择手动安装Sproutvideo,因为那比您想象的要麻烦得多。事实上,正如您发现的那样,它根本无法让您使用Composer来安装Guzzle。使用共享主机时(甚至

php - Laravel 中的 Guzzle 客户端 : InvalidArgumentException: "No method is configured to handle the form_params config key"

我正在尝试使用Guzzle客户端向API发送请求,但收到一条错误消息,InvalidArgumentException:"Nomethodisconfiguredtohandletheform_paramsconfigkey"这是我试过的:$response=$this->guzzle->post("https://example.com",['form_params'=>['client_id'=>$this->client_id,'authorization_code'=>$this->authorization_code,'decoder_query'=>$this->reque

php - guzzle ver 6 发布方法不起作用

在postman工作(原始格式数据与application/json类型)带Guzzle6url-http://vm.xxxxx.com/v1/hirejob/{"company_name":"company_name","last_date_apply":"06/12/2015","rid":"89498"}所以我正在创建响应201但在Guzzle$client=newClient();$data=array();$data['company_name']="company_name";$data['last_date_apply']="06/12/2015";$data['rid'