Guzzle无法绕过cURL错误35:SSL连接错误
使用Guzzle 6我试图与使用自签名证书的HTTPS端点进行通信. 我正在实例化我的客户类,如下所示: $authClient = new Client([ 'base_uri' => config('app.auth_uri'), 'verify' => false ]); 尝试请求: $res = $this->authClient->request('POST', '/auth', [ 'form_params' => [ 'client_id' => 'XXXXXXXXXXXXXXX', 'username' => 'RSA', 'grant_type' => 'password' ] ]); 这是我遇到的错误: cURL error 35: SSL connect error (see http://curl.haxx
0 2023-06-01
编程技术问答社区
PHP应用程序中的Guzzle池
我试图在PHP中使用Guzzle池.但是我很难处理异步请求.以下是代码片段. $client = new \GuzzleHttp\Client(); function test() { $client = new \GuzzleHttp\Client(); $request = $client->createRequest('GET', 'http://l/?n=0', ['future' => true]); $client->send($request)->then(function ($response) { //echo 'Got a response! ' . $response; return "\n".$response->getBody(); }); } $res = test(); var_dum
0 2023-06-01
编程技术问答社区
用带有原始数据的guzzle发送请求
我想发送一个看起来像这样的guzzle的请求. 是,我总是得到 uncured异常'guzzlehttp \ exception \ clientException'with messages'客户端错误:POST http://localhost:8080/project/user/login导致400 Bad Request 这是代码创建并发送请求的一部分: if (isset ($_REQUEST['username']) && isset($_REQUEST['password'])){ require '../php/vendor/autoload.php'; $myClient = new GuzzleHttp\Client(); $request = $myClient->post("http://localhost:8080/project/user/login"); $request->setBody($_REQUEST['username'
0 2023-06-01
编程技术问答社区
使用put/post将数据发送到Laravel中的webservice
我正在尝试创建一种动态方法,以使用guzzle和laravel 使用网络服务发送/接收我的数据 我的控制器中有以下结构 class TipoProjetoController extends Controller { private $Tabela = 'tipoprojeto'; public function AppWebService($Who, $Type, $Data) { $Client = new Client(['base_uri' => config('constants.caminhoWS').$Who]); $response = $Client->request($Type, $Data); return $response->getBody()->getContents(); } public function index()
0 2023-05-31
编程技术问答社区
正确地使用GuzzleHttp/Psr7/Response
不确定在PHP页面中显示的正确方法是什么. 现在,我正在做: use GuzzleHttp\Psr7\BufferStream; use GuzzleHttp\Psr7\Response; class Main extends \pla\igg\Main { function __construct() { $stream = new BufferStream(); $stream->write("Hello I am a buffer"); $response = new Response(); $response = $response->withBody($stream); $response = $response->withStatus('201'); $response = $response->withHeader("Content-type",
0 2023-05-31
编程技术问答社区
在Laravel 8中捕获HTTP客户错误8
您如何捕获 http client (例如(例如)(例如,超时),以免在laraval调试器(在调试模式下)中丢弃卷曲错误,然后才能避免停止执行? use Illuminate\Support\Facades\Http; try { $request = Http::post('https://example.com/post', [ 'password' => 'guest']); } catch(ConnectException $e) { //log error } //continue with another mode 相反,我总是得到Laravel的点火错误页面 Illuminate\Http\Client\ConnectionException cURL error 28: Failed to connect to example.com port 443:
0 2023-05-31
编程技术问答社区
laravel guzzlehttp xml对JSON的响应
我正在打电话给Namecheap的API,他们返回XML响应. 尝试输出此内容时,我得到响应null. 击中相同的API,但是使用Google Extension Postman,我得到了我追求的结果,我在响应中做错了什么? public function testCheck($domains){ $client = new Client(); $res = $client->request('GET', 'https://api.namecheap.com/xml.response?ApiUser=(username)&ApiKey=(apikey)&UserName(username)&ClientIp=(ip)&Command=namecheap.domains.check&DomainList=' . $domains); $data = json_decode($res->getBody()); dd($data); } 我
0 2023-05-31
编程技术问答社区
遍历亚马逊S3上一个文件夹中的对象
我们有一个应用程序,在用户中可以创建自己的网页并托管它们.我们正在使用S3来存储它们是静态的页面.存储桶中每个用户的文件夹. 现在,如果用户想在他的域上托管他的网站,我们请他索要域名(启动时,我们将其发布在我们的子域上),我必须重命名该文件夹. s3是一个平坦的文件系统,我知道实际上没有文件夹,但只有分隔器/分隔值,因此我无法进入文件夹并检查其中包含多少页.API允许它一个一个一个,但为此我们必须知道存储桶中的对象名称. 我浏览了文档,碰到迭代器,我尚未实施.这使用实施 的经验和面临挑战 我还有其他路径还是我需要这样的路. 解决方案 您可以通过执行以下内容为"文件夹"中的内容创建迭代器: $objects = $s3->getIterator('ListObjects', array( 'Bucket' => 'bucket-name', 'Prefix' => 'subfolder-name/', 'Delim
0 2023-05-31
编程技术问答社区
用PHP和Guzzle传输远程文件
我的应用程序应将其流回浏览器一个大文件,这是远程服务器.目前,该文件是从本地Nodejs服务器提供的. 我正在使用25GB的虚拟盒磁盘映像,只是为了确保它在流中时未存储在内存中. 这是我正在努力 的相关代码 require __DIR__ . '/vendor/autoload.php'; use GuzzleHttp\Stream\Stream; use GuzzleHttp\Stream\LimitStream; $client = new \GuzzleHttp\Client(); logger('==== START REQUEST ===='); $res = $client->request('GET', 'http://localhost:3002/', [ 'on_headers' => function (\Psr\Http\Message\ResponseInterface $response)
0 2023-05-31
编程技术问答社区
使用卷曲或guzzle的laravel passport oauth函数
我在API路线文件中有此路线 Route::post('/user/register', 'HomeController@register'); ,寄存器功能为 public function register(Request $request) { $user = User::create([ ... ]); return $this->getAccessToken($request); } public function getAccessToken(Request $request) { $url = url('/oauth/token'); $headers = ['Accept' => 'application/json']; $http = new Client; $response = $http->post($url, [ 'headers' => $header
0 2023-05-31
编程技术问答社区
如何处理致命错误:cURL错误7:连接XXXX端口443失败
我有一个连接到第三方API的脚本.它是并且应该在24/7的不间断循环上运行(在重新启动循环之前,我在末端使用睡眠). 问题是,有时第三方API被插入,或者连接只是在此错误中掉落: 致命错误:未被发现的例外 " guzzlehttp \ ring \异常\ connectException"带有消息'卷曲错误 7:无法连接到xxx.com端口443 是否有任何方法可以在此致命错误上"打破"以确保代码重新启动,并在执行操作时继续进行操作,或者我每次遇到此错误时都必须手动重新启动吗? 解决方案 来自 Michael's 注释 看起来您只需抓住guzzlehttp \ ring \异常\ connectException exception 这样: use GuzzleHttp\Ring\Exception\ConnectException; try { // the code which throws the error } catch(
4 2023-05-31
编程技术问答社区
Sage One API-unsupported_grant_type
我试图通过遵循,试图获得Sage One API的访问令牌docs 使用 错误 Client error: `POST https://api.sageone.com/oauth2/token` resulted in a `400 Bad Request` response: {"error":"unsupported_grant_type"} 有问题的代码 $client = new Client([ 'base_uri'=>'https://api.sageone.com', 'headers' => ['content_type' => 'application/x-www-form-urlencoded'] ]); $data = [ 'client_id' => getenv('SAGE_CLIENT'), 'client_secret' => getenv('SAGE_
0 2023-05-31
编程技术问答社区
Prestashop 1.6,冲突:2个不同的模块需要相同的类,不同的版本
在我的Prestashop项目中,我有几个模块.在其中一个(让我们称之为" AWS")中,我使用Composer(在PhpStorm中)安装了 aws sdk ,如说明另一方面,还有另一个模块(让我们称其为" orangeconnect" )与作曲家一样,它具有较早版本的" guzzlehttp". 当我在第一个模块中的PHP脚本内使用AWS SDK时,问题就在于.发生的事情是它试图称呼URI作曲家类,并崩溃.实际上,由于一个类" Uriresolver"的不存在.问题是,如果我删除" OrangeConnect",则AWS SDK正确连接,这意味着由于" OrangeConnect"模块," AWS"中的URI类不正确.但是,我迫切需要支持项目中的" orangeconnect". 总而言之, 在PRESTASHOP内部的PHP中的这种冲突 中,并允许每个模块包含guzzlehttp 的相应有效版本,而没有任何冲突 ? 谢谢. 解决方案 如果orangeCon
0 2023-05-31
编程技术问答社区
Laravel Class 'App\Http\Controllers\GuzzleHttp\Client' not found
我已经安装了客户端,我使用 Composer dump autoLoad 进行了更新,但最终还是出现相同的错误.通过作曲家安装后,需要guzzlehttp/guzzle:〜6.0在项目目录中. $client = new GuzzleHttp\Client(); 为什么它可以工作,为什么它甚至引用错误的目录? 解决方案 您将要熟悉PHP nesspaces . Laravel中的大多数文件都是名称的.在该名称空间内启动了命名空间内函数的调用,但两个例外: 如果您使用\启动类名,则告诉PHP从根级命名空间开始: $client = new \GuzzleHttp\Client(); 或者,您可以放置​​: use GuzzleHttp\Client; 在文件的顶部(您会在Laravel的默认文件中看到这些已经 lot ),然后进行 $client = new Client(); 其他解决方案 您可能没有安装Guzzle.
0 2023-05-31
编程技术问答社区
POST请求在Postman中可以使用,但在Guzzle中不能使用
在我的Laravel应用程序中,我需要定期使用Guzzle将数据发布到API中. API用户是一个携带者令牌,可以进行身份​​验证,并请求并接受RAW JSON.为了测试,我使用Postman访问了API,一切都很好. 邮递员标题: Accept:application/json Authorization:Bearer [token] Content-Type:application/json 和Postman主体: { "request1" : "123456789", "request2" : "2468", "request3" : "987654321", "name" : "John Doe" } Postman返回200,而JSON对象作为响应. 现在,当我尝试使用Guzzle进行同样的尝试时,我会得到200个状态代码,但是没有JSON对象会返回.这是我的guzzle实施: public funct
0 2023-05-30
编程技术问答社区
Class 'Guzzle\Http\Client'not found
我正在尝试在SitePoint http://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'; use Guzzle\Http\Client; use Guzzle\Http\EntityBody; use Guzzle\Http\Message\Request; use Guzzle\Http\Message\Response;
0 2023-05-30
编程技术问答社区
使用Guzzle检查远程文件是否存在的最好方法是什么?
我想使用guzzle检查是否存在远程文件. 这是我当前检查的一个示例: /** * @return boolean */ function exists() { // By default get_headers uses a GET request to fetch the headers. // Send a HEAD request instead stream_context_set_default( array( 'http' => array( 'method' => 'HEAD' ) ) ); // Get the file headers $file_headers = @get_headers($this->file); // Check file headers for 404
2 2023-05-30
编程技术问答社区
为Guzzle转换这个cURL
我已经尝试阅读Guzzle文档,但我无法围绕这个问题缠住头. 我想使用guzzle而不是卷曲以进行以下内容: protected $url = 'https://secure.abcdef.com/cgi/xml_request_server.php'; $xml = "\n"; $xml .= "\n"; $xml .= "$this->gwlogin\n"; $xml .= "$this->gwkey\n"; $xml .= "\n"; $xml .= "\n"; $xml .= "SearchABC\n";
0 2023-05-30
编程技术问答社区
Composer自动加载器没有加载GuzzleHttp\ClientInterface
我正在尝试使用 guzzle ,但是我得到了以下致命错误: 致命错误:'guzzlehttp \ clientinterface' /var/www/myapp/vendor/guzzlehttp/guzzle/src/functions.php on 13 我正在使用作曲家自动加载器自动加载: require 'vendor/autoload.php'; use Guzzle\Http\Client; $client = new Client(); $requests = Array( $client->createRequest('GET', 'ams1.myapp.com:8080/api/ffmpeg_make_snapshots.php'), $client->createRequest('GET', 'ams2.myapp.com:8080/api/ffmpeg_make_snapshots.php'), $client->cr
0 2023-05-30
编程技术问答社区