{"id":5491,"date":"2024-05-04T14:22:29","date_gmt":"2024-05-04T05:22:29","guid":{"rendered":"https:\/\/taitan916.info\/blog\/?p=5491"},"modified":"2024-03-15T14:34:51","modified_gmt":"2024-03-15T05:34:51","slug":"post-5491","status":"publish","type":"post","link":"https:\/\/taitan916.info\/blog\/archives\/5491","title":{"rendered":"PHP\u306eHTTP\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u7528\u30e9\u30a4\u30d6\u30e9\u30ea\u300cGuzzle\u300d\u306e\u5229\u7528\u65b9\u6cd5"},"content":{"rendered":"<p>\u4ee5\u524d\u306b<a href=\"https:\/\/taitan916.info\/blog\/archives\/5314\" target=\"_blank\" rel=\"noopener\">\u300cRequests for PHP\u300d\u3092\u8a66\u3057\u305f<\/a>\u304c\u3001\u4f3c\u305f\u3088\u3046\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u300cGuzzle\u300d\u304c\u3042\u308b\u3002\u3053\u3061\u3089\u306e\u65b9\u304c\u6709\u540d\u3089\u3057\u3044\u306e\u3067\u8a66\u3057\u3066\u307f\u305f\u3044\u3002\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u5c0e\u5165\u65b9\u6cd5\u3068\u5916\u90e8API\u30b5\u30fc\u30d3\u30b9\u3068\u306e\u63a5\u7d9a\u65b9\u6cd5\u306b\u3064\u3044\u3066\u30e1\u30e2\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2><span id=\"i\">\u3084\u308a\u305f\u3044\u3053\u3068<\/span><\/h2>\n<ul>\n<li>Guzzle\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/li>\n<li><a href=\"https:\/\/zipcloud.ibsnet.co.jp\/\" target=\"_blank\" rel=\"noopener\">\u90f5\u4fbf\u756a\u53f7\u30c7\u30fc\u30bf\u914d\u4fe1\u30b5\u30fc\u30d3\u30b9<\/a>\u306eAPI\u306b\u30ea\u30af\u30a8\u30b9\u30c8<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2>Guzzle<\/h2>\n<h3><span id=\"i-2\">\u516c\u5f0f\u30b5\u30a4\u30c8<\/span><\/h3>\n<p><a href=\"https:\/\/github.com\/guzzle\/guzzle\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/guzzle\/guzzle<\/a><\/p>\n<h3><span id=\"i-3\">\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/span><\/h3>\n<p><a href=\"https:\/\/docs.guzzlephp.org\/en\/stable\/index.html\" target=\"_blank\" rel=\"noopener\">https:\/\/docs.guzzlephp.org\/en\/stable\/index.html<\/a><\/p>\n<p>&nbsp;<\/p>\n<h2><span id=\"i-4\">\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/span><\/h2>\n<p>SSH\u63a5\u7d9a\u3057\u4ee5\u4e0b\u30b3\u30de\u30f3\u30c9\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3002<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">composer require guzzlehttp\/guzzle<\/pre>\n<p>&nbsp;<\/p>\n<h2><span id=\"i-5\">\u5b9f\u88c5\u65b9\u6cd5<\/span><\/h2>\n<h3><span id=\"i-6\">\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9<\/span><\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;?php\r\nrequire 'vendor\/autoload.php';\r\n\r\n$url = 'https:\/\/zipcloud.ibsnet.co.jp\/api\/search';\r\n$data = array('zipcode' =&gt; '1050003');\r\n\r\n$client = new \\GuzzleHttp\\Client();\r\n$request = $client-&gt;request('POST', $url, ['form_params' =&gt; $data]);\r\n\r\nif( $request-&gt;getStatusCode() == 200 ){\r\n    echo ($request-&gt;getBody());\r\n}else{\r\n    \/\/\u30a8\u30e9\u30fc\u6642\u306e\u51e6\u7406\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<h2>\u6240\u611f<\/h2>\n<p>Requests for PHP\u306f\u30e9\u30a4\u30d6\u30e9\u30ea\u540d\u306e\u554f\u984c\u304b\u65e5\u672c\u8a9e\u60c5\u5831\u304c\u691c\u7d22\u3057\u3065\u3089\u3044\u3057\u3001\u3042\u307e\u308a\u30d2\u30c3\u30c8\u3057\u306a\u3044\u3002<\/p>\n<p>Guzzle\u306f\u65e5\u672c\u8a9e\u60c5\u5831\u304c\u591a\u6570\u898b\u3064\u304b\u3063\u305f\u306e\u3067\u305d\u3046\u3044\u3063\u305f\u90e8\u5206\u3067\u306f\u6271\u3044\u3084\u3059\u3044\u304b\u3082\u3002<\/p>\n<p>\u305f\u3060\u3001Guzzle\u306fComposer\u5fc5\u9808\u3063\u307d\u3044\u306e\u3067\u5f53\u9762\u306fRequests for PHP\u3092\u4f7f\u3063\u3066\u307f\u3066\u30c0\u30e1\u3060\u3063\u305f\u3089Guzzle\u306b\u79fb\u308d\u3046\u304b\u3068\u601d\u3046\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ee5\u524d\u306b\u300cRequests for PHP\u300d\u3092\u8a66\u3057\u305f\u304c\u3001\u4f3c\u305f\u3088\u3046\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u300cG ... <\/p>\n","protected":false},"author":1,"featured_media":1085,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2],"tags":[100],"class_list":["post-5491","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","tag-library"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts\/5491","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/comments?post=5491"}],"version-history":[{"count":2,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts\/5491\/revisions"}],"predecessor-version":[{"id":5493,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts\/5491\/revisions\/5493"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/media\/1085"}],"wp:attachment":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/media?parent=5491"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/categories?post=5491"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/tags?post=5491"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}