はじめに LaravelでHTTPリクエストを投げたかったのでGuzzleを使ってみました。 以前ですとPEARのHTTP_Request2を使っていましたが、あまり最近使われていないようなので新しいパッケージを使ってみました。 HTTP_Request2は長年使ってまして、使いやすくて好きです。cURLも悪くはないのですが…。 Laravelで使いましたが、もちろん生のPHPでも使えます。 Laravelのラッパー Laravel 7系ではGuzzleラッパーが提供されているようです。 例 $response = Http::post('http://test.com/users', [ 'name' => 'Steve', 'role' => 'Network Administrator', ]); $ laravel new hogeproject $ cd hogeproject
環境 PHP5.6 Guzzle6.3 公式ドキュメント: http://docs.guzzlephp.org/en/stable/index.html guzzle インストール composerでインストールします。 require_once(dirname(__FILE__) . '/vendor/autoload.php'); use GuzzleHttp\Client; $client = new Client(); //$client = new \GuzzleHttp\Client(['cookies' => true]); //クッキーを利用したい場合 //$client = new \GuzzleHttp\Client(['debug' => true]); //通信内容をデバッグしたい場合 $promises[] = $client->requestAsync('GET
Guzzle Documentation¶ Guzzle is a PHP HTTP client that makes it easy to send HTTP requests and trivial to integrate with web services. Simple interface for building query strings, POST requests, streaming large uploads, streaming large downloads, using HTTP cookies, uploading JSON data, etc... Can send both synchronous and asynchronous requests using the same interface. Uses PSR-7 interfaces for r
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く