{"id":2466,"date":"2025-03-24T08:47:13","date_gmt":"2025-03-23T23:47:13","guid":{"rendered":"https:\/\/dexall.co.jp\/articles\/?p=2466"},"modified":"2025-03-24T08:47:43","modified_gmt":"2025-03-23T23:47:43","slug":"guzzle%e3%81%ae%e5%ae%9f%e8%b7%b5%e3%82%ac%e3%82%a4%e3%83%89%ef%bc%9aphp%e3%81%a7%e3%81%aehttp%e3%83%aa%e3%82%af%e3%82%a8%e3%82%b9%e3%83%88%e5%87%a6%e7%90%86%e3%82%92%e5%8a%87%e7%9a%84%e3%81%ab","status":"publish","type":"post","link":"https:\/\/dexall.co.jp\/articles\/?p=2466","title":{"rendered":"Guzzle\u306e\u5b9f\u8df5\u30ac\u30a4\u30c9\uff1aPHP\u3067\u306eHTTP\u30ea\u30af\u30a8\u30b9\u30c8\u51e6\u7406\u3092\u5287\u7684\u306b\u6539\u5584\u3059\u308b7\u3064\u306e\u30c6\u30af\u30cb\u30c3\u30af"},"content":{"rendered":"\n<div class=\"toc\"><br \/>\n<b>Warning<\/b>:  Undefined array key \"is_admin\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>116<\/b><br \/>\n<br \/>\n<b>Warning<\/b>:  Undefined array key \"is_category_top\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>121<\/b><br \/>\n<br \/>\n<b>Warning<\/b>:  Undefined array key \"is_top\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>128<\/b><br \/>\n    <div id=\"toc_container\" class=\"sgb-toc--bullets js-smooth-scroll\" data-dialog-title=\"\u76ee\u6b21\">\n      <p class=\"toc_title\">\u76ee\u6b21 <\/p>\n      <ul class=\"toc_list\">  <li class=\"first\">    <a href=\"#i-0\">Guzzle\u3068\u306f\uff1a\u30e2\u30c0\u30f3\u306aPHP\u306eHTTP\u30af\u30e9\u30a4\u30a2\u30f3\u30c8<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-1\">\u5f93\u6765\u306ecURL\u3068\u306e\u6c7a\u5b9a\u7684\u306a\u9055\u3044<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-2\">Guzzle\u304c\u89e3\u6c7a\u3059\u308b3\u3064\u306e\u8ab2\u984c<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-3\">Guzzle\u306e\u57fa\u672c\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3068\u521d\u671f\u8a2d\u5b9a<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-4\">Composer\u3092\u4f7f\u7528\u3057\u305f\u6700\u65b0\u7248\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u65b9\u6cd5<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-5\">\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3078\u306e\u5c0e\u5165\u3068\u57fa\u672c\u8a2d\u5b9a<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-10\">HTTP\u30ea\u30af\u30a8\u30b9\u30c8\u51e6\u7406\u3092\u6539\u5584\u3059\u308b7\u3064\u306e\u30c6\u30af\u30cb\u30c3\u30af<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-11\">\u975e\u540c\u671f\u30ea\u30af\u30a8\u30b9\u30c8\u306b\u3088\u308b\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u5411\u4e0a<\/a>      <\/li>      <li>        <a href=\"#i-12\">\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u3092\u6d3b\u7528\u3057\u305f\u30ea\u30af\u30a8\u30b9\u30c8\/\u30ec\u30b9\u30dd\u30f3\u30b9\u51e6\u7406\u306e\u81ea\u52d5\u5316<\/a>      <\/li>      <li>        <a href=\"#i-13\">\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u306e\u5b9f\u88c5\u3068\u30ea\u30c8\u30e9\u30a4\u6226\u7565<\/a>      <\/li>      <li>        <a href=\"#i-14\">\u8a8d\u8a3c\u51e6\u7406\u306e\u52b9\u7387\u7684\u306a\u5b9f\u88c5\u65b9\u6cd5<\/a>      <\/li>      <li>        <a href=\"#i-15\">\u30ec\u30b9\u30dd\u30f3\u30b9\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u6226\u7565<\/a>      <\/li>      <li>        <a href=\"#i-16\">\u30e2\u30c3\u30af\u3092\u4f7f\u7528\u3057\u305f\u30c6\u30b9\u30c8\u5b9f\u88c5<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-17\">\u5927\u898f\u6a21\u30b7\u30b9\u30c6\u30e0\u3067\u306eGuzzle\u30d7\u30fc\u30eb\u306e\u6d3b\u7528<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-18\">\u5b9f\u8df5\u7684\u306a\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u3068\u5b9f\u88c5\u4f8b<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-19\">REST API\u3068\u306e\u9023\u643a\u5b9f\u88c5<\/a>      <\/li>      <li>        <a href=\"#i-20\">OAuth\u8a8d\u8a3c\u306e\u5b9f\u88c5\u30d1\u30bf\u30fc\u30f3<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-21\">Webhook\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-22\">\u5b9f\u8df5\u7684\u306a\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u3068\u5b9f\u88c5\u4f8b<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-23\">REST API\u3068\u306e\u9023\u643a\u5b9f\u88c5<\/a>      <\/li>      <li>        <a href=\"#i-24\">OAuth\u8a8d\u8a3c\u306e\u5b9f\u88c5\u30d1\u30bf\u30fc\u30f3<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-25\">Webhook\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-26\">Guzzle\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-27\">\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u306e\u6700\u9069\u5316\u30c6\u30af\u30cb\u30c3\u30af<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-28\">\u540c\u6642\u63a5\u7d9a\u6570\u306e\u9069\u5207\u306a\u8a2d\u5b9a\u65b9\u6cd5<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-29\">Guzzle\u306e\u904b\u7528\u3068\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-30\">\u5b9f\u904b\u7528\u3067\u306e\u76e3\u8996\u30dd\u30a4\u30f3\u30c8<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-31\">\u3088\u304f\u3042\u308b\u30a8\u30e9\u30fc\u3068\u305d\u306e\u89e3\u6c7a\u65b9\u6cd5<\/a>      <\/li>    <\/ul>  <\/li>  <li class=\"last\">    <a href=\"#i-33\">\u307e\u3068\u3081\uff1a\u6b21\u4e16\u4ee3\u306eHTTP\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u30e9\u30a4\u30d6\u30e9\u30ea\u3068\u3057\u3066\u306eGuzzle<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-34\">Guzzle\u5c0e\u5165\u304c\u3082\u305f\u3089\u3059\u958b\u767a\u52b9\u7387\u306e\u5411\u4e0a<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-35\">\u4eca\u5f8c\u306e\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u3068\u6ce8\u76ee\u3059\u3079\u304d\u65b0\u6a5f\u80fd<\/a>      <\/li>    <\/ul>  <\/li><\/ul>\n      <a href=\"#\" class=\"sgb-toc-button js-toc-button\" rel=\"nofollow\" data-open-dialog=\"true\"><i class=\"fa fa-list\"><\/i><span class=\"sgb-toc-button__text\">\u76ee\u6b21\u3078<\/span><\/a>\n    <\/div><\/div><h2 class=\"wp-block-heading\" id=\"i-0\">Guzzle\u3068\u306f\uff1a\u30e2\u30c0\u30f3\u306aPHP\u306eHTTP\u30af\u30e9\u30a4\u30a2\u30f3\u30c8<\/h2>\n\n\n\n<p>Guzzle\u306f\u3001PHP\u3067\u6700\u3082\u5e83\u304f\u4f7f\u7528\u3055\u308c\u3066\u3044\u308bHTTP\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3059\u3002\u73fe\u4ee3\u306eWeb\u958b\u767a\u306b\u304a\u3044\u3066\u3001\u5916\u90e8API\u3068\u306e\u9023\u643a\u3084\u3001\u30de\u30a4\u30af\u30ed\u30b5\u30fc\u30d3\u30b9\u9593\u306e\u901a\u4fe1\u306f\u4e0d\u53ef\u6b20\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u305d\u3093\u306a\u4e2d\u3001Guzzle\u306fPHP\u3067\u306eHTTP\u901a\u4fe1\u3092\u5287\u7684\u306b\u6539\u5584\u3057\u3001\u958b\u767a\u8005\u306e\u751f\u7523\u6027\u3092\u5411\u4e0a\u3055\u305b\u308b\u5f37\u529b\u306a\u30c4\u30fc\u30eb\u3068\u3057\u3066\u6ce8\u76ee\u3092\u96c6\u3081\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-1\">\u5f93\u6765\u306ecURL\u3068\u306e\u6c7a\u5b9a\u7684\u306a\u9055\u3044<\/h3>\n\n\n\n<p>\u5f93\u6765\u306ePHP\u3067\u306eHTTP\u901a\u4fe1\u3068\u3044\u3048\u3070\u3001cURL\u62e1\u5f35\u304c\u4e00\u822c\u7684\u3067\u3057\u305f\u3002\u3057\u304b\u3057\u3001cURL\u306b\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u8ab2\u984c\u304c\u3042\u308a\u307e\u3057\u305f\uff1a<\/p>\n\n\n<div id=\"id-36390345-b1fa-47cf-a989-372f44b5b35a\">\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u89b3\u70b9<\/th><th>cURL<\/th><th>Guzzle<\/th><\/tr><\/thead><tbody><tr><td>\u30b3\u30fc\u30c9\u53ef\u8aad\u6027<\/td><td>\u624b\u7d9a\u304d\u7684\u3067\u5197\u9577<\/td><td>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\u3067\u76f4\u611f\u7684<\/td><\/tr><tr><td>\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0<\/td><td>try-catch\u306b\u3088\u308b\u57fa\u672c\u7684\u306a\u4f8b\u5916\u51e6\u7406\u306e\u307f<\/td><td>\u8a73\u7d30\u306a\u30a8\u30e9\u30fc\u60c5\u5831\u3068\u67d4\u8edf\u306a\u4f8b\u5916\u51e6\u7406<\/td><\/tr><tr><td>\u975e\u540c\u671f\u51e6\u7406<\/td><td>\u8907\u96d1\u306a\u5b9f\u88c5\u304c\u5fc5\u8981<\/td><td>Promise API\u306b\u3088\u308b\u7c21\u6f54\u306a\u5b9f\u88c5<\/td><\/tr><tr><td>\u30c6\u30b9\u30c8\u5bb9\u6613\u6027<\/td><td>\u30e2\u30c3\u30af\u4f5c\u6210\u304c\u56f0\u96e3<\/td><td>\u30c6\u30b9\u30c8\u7528\u306e\u30e2\u30c3\u30af\u30cf\u30f3\u30c9\u30e9\u3092\u6a19\u6e96\u63d0\u4f9b<\/td><\/tr><tr><td>\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u5bfe\u5fdc<\/td><td>\u72ec\u81ea\u5b9f\u88c5\u304c\u5fc5\u8981<\/td><td>\u8c4a\u5bcc\u306a\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u30a8\u30b3\u30b7\u30b9\u30c6\u30e0<\/td><\/tr><\/tbody><\/table><\/figure>\n<\/div>\n\n\n<p>\u7279\u306b\u6ce8\u76ee\u3059\u3079\u304d\u306f\u3001Guzzle\u304c\u63d0\u4f9b\u3059\u308b\u30e2\u30c0\u30f3\u306aAPI\u8a2d\u8a08\u3067\u3059\u3002\u4f8b\u3048\u3070\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u76f4\u611f\u7684\u306a\u30b3\u30fc\u30c9\u8a18\u8ff0\u304c\u53ef\u80fd\u3067\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ cURL\u306e\u5834\u5408\n$ch = curl_init();\ncurl_setopt($ch, CURLOPT_URL, \"https:\/\/api.example.com\/data\");\ncurl_setopt($ch, CURLOPT_RETURNTRANSFER, true);\n$response = curl_exec($ch);\ncurl_close($ch);\n\n\/\/ Guzzle\u306e\u5834\u5408\n$client = new GuzzleHttp\\Client();\n$response = $client-&gt;get('https:\/\/api.example.com\/data');<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-2\">Guzzle\u304c\u89e3\u6c7a\u3059\u308b3\u3064\u306e\u8ab2\u984c<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u975e\u540c\u671f\u51e6\u7406\u306e\u7c21\u7565\u5316<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Promise\u30d9\u30fc\u30b9\u306e\u975e\u540c\u671f\u51e6\u7406\u306b\u3088\u308a\u3001\u8907\u6570\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u52b9\u7387\u7684\u306b\u51e6\u7406<\/li>\n\n\n\n<li>\u4e26\u5217\u30ea\u30af\u30a8\u30b9\u30c8\u306b\u3088\u308b\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u5411\u4e0a<\/li>\n\n\n\n<li>\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u5730\u7344\u306e\u89e3\u6d88<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u306e\u5f37\u5316<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>HTTP\u30a8\u30e9\u30fc\u306e\u81ea\u52d5\u691c\u51fa<\/li>\n\n\n\n<li>\u8a73\u7d30\u306a\u30a8\u30e9\u30fc\u60c5\u5831\u306e\u63d0\u4f9b<\/li>\n\n\n\n<li>\u30ea\u30c8\u30e9\u30a4\u6a5f\u80fd\u306e\u7d44\u307f\u8fbc\u307f<\/li>\n\n\n\n<li>\u30ab\u30b9\u30bf\u30e0\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30e9\u306e\u5b9f\u88c5\u304c\u5bb9\u6613<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30c6\u30b9\u30c8\u5bb9\u6613\u6027\u306e\u5411\u4e0a<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30e2\u30c3\u30af\u30cf\u30f3\u30c9\u30e9\u306b\u3088\u308b\u5916\u90e8API\u306e\u30b7\u30df\u30e5\u30ec\u30fc\u30b7\u30e7\u30f3<\/li>\n\n\n\n<li>\u30ec\u30b9\u30dd\u30f3\u30b9\u306e\u30b9\u30bf\u30d6\u5316\u304c\u5bb9\u6613<\/li>\n\n\n\n<li>\u30c6\u30b9\u30c8\u306e\u4fe1\u983c\u6027\u5411\u4e0a<\/li>\n<\/ul>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u7279\u5fb4\u306b\u3088\u308a\u3001Guzzle\u306f\u5358\u306a\u308bHTTP\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u8d85\u3048\u3066\u3001PHP\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u54c1\u8cea\u3068\u4fdd\u5b88\u6027\u3092\u5411\u4e0a\u3055\u305b\u308b\u91cd\u8981\u306a\u30c4\u30fc\u30eb\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001Guzzle\u306e\u5177\u4f53\u7684\u306a\u5c0e\u5165\u65b9\u6cd5\u3068\u57fa\u672c\u7684\u306a\u8a2d\u5b9a\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-3\">Guzzle\u306e\u57fa\u672c\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3068\u521d\u671f\u8a2d\u5b9a<\/h2>\n\n\n\n<p>Guzzle\u3092\u52b9\u679c\u7684\u306b\u6d3b\u7528\u3059\u308b\u305f\u3081\u306b\u306f\u3001\u9069\u5207\u306a\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3068\u521d\u671f\u8a2d\u5b9a\u304c\u91cd\u8981\u3067\u3059\u3002\u3053\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3078\u306eGuzzle\u306e\u5c0e\u5165\u304b\u3089\u57fa\u672c\u7684\u306a\u8a2d\u5b9a\u65b9\u6cd5\u307e\u3067\u3001\u5b9f\u8df5\u7684\u306a\u30a2\u30d7\u30ed\u30fc\u30c1\u3092\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-4\">Composer\u3092\u4f7f\u7528\u3057\u305f\u6700\u65b0\u7248\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u65b9\u6cd5<\/h3>\n\n\n\n<p>Guzzle\u306f\u3001Composer\u3092\u4f7f\u7528\u3057\u3066\u7c21\u5358\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3067\u304d\u307e\u3059\u3002\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u6700\u65b0\u306e\u5b89\u5b9a\u7248\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3067\u304d\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">composer require guzzlehttp\/guzzle<\/pre>\n\n\n\n<p>\u7279\u5b9a\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u5834\u5408\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u6307\u5b9a\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">composer require guzzlehttp\/guzzle:^7.0<\/pre>\n\n\n\n<p>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u5f8c\u3001composer.json\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u4f9d\u5b58\u95a2\u4fc2\u304c\u8ffd\u52a0\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">{\n    \"require\": {\n        \"guzzlehttp\/guzzle\": \"^7.0\"\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-5\">\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3078\u306e\u5c0e\u5165\u3068\u57fa\u672c\u8a2d\u5b9a<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-6\">1. \u57fa\u672c\u7684\u306a\u521d\u671f\u5316<\/h4>\n\n\n\n<p>Guzzle\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306e\u521d\u671f\u5316\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30d1\u30bf\u30fc\u30f3\u3092\u63a8\u5968\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\nrequire 'vendor\/autoload.php';\n\nuse GuzzleHttp\\Client;\nuse GuzzleHttp\\Exception\\GuzzleException;\n\n\/\/ \u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306e\u57fa\u672c\u8a2d\u5b9a\n$client = new Client([\n    'base_uri' =&gt; 'https:\/\/api.example.com',\n    'timeout'  =&gt; 5.0,\n    'headers' =&gt; [\n        'Accept' =&gt; 'application\/json',\n        'User-Agent' =&gt; 'MyApp\/1.0'\n    ]\n]);<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-7\">2. \u5171\u901a\u8a2d\u5b9a\u306e\u5b9a\u7fa9<\/h4>\n\n\n\n<p>\u5927\u898f\u6a21\u306a\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067\u306f\u3001\u8a2d\u5b9a\u3092\u96c6\u4e2d\u7ba1\u7406\u3059\u308b\u3053\u3068\u3092\u304a\u52e7\u3081\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\nclass GuzzleConfig\n{\n    public static function getDefaultConfig(): array\n    {\n        return [\n            'connect_timeout' =&gt; 5,\n            'timeout' =&gt; 10,\n            'http_errors' =&gt; true,\n            'verify' =&gt; true,  \/\/ SSL\u8a3c\u660e\u66f8\u306e\u691c\u8a3c\n            'defaults' =&gt; [\n                'headers' =&gt; [\n                    'Accept' =&gt; 'application\/json',\n                    'Content-Type' =&gt; 'application\/json'\n                ]\n            ]\n        ];\n    }\n}\n\n\/\/ \u4f7f\u7528\u4f8b\n$client = new Client(GuzzleConfig::getDefaultConfig());<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-8\">3. \u74b0\u5883\u5225\u306e\u8a2d\u5b9a\u7ba1\u7406<\/h4>\n\n\n\n<p>\u958b\u767a\u74b0\u5883\u3068\u672c\u756a\u74b0\u5883\u3067\u7570\u306a\u308b\u8a2d\u5b9a\u3092\u4f7f\u7528\u3059\u308b\u5834\u5408\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30a2\u30d7\u30ed\u30fc\u30c1\u304c\u52b9\u679c\u7684\u3067\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\nclass GuzzleConfigFactory\n{\n    public static function createConfig(string $environment): array\n    {\n        $baseConfig = [\n            'timeout' =&gt; 5.0,\n            'http_errors' =&gt; true\n        ];\n\n        switch ($environment) {\n            case 'production':\n                return array_merge($baseConfig, [\n                    'verify' =&gt; true,\n                    'connect_timeout' =&gt; 3.0\n                ]);\n            case 'development':\n                return array_merge($baseConfig, [\n                    'verify' =&gt; false,  \/\/ \u958b\u767a\u74b0\u5883\u3067\u306fSSL\u691c\u8a3c\u3092\u7121\u52b9\u5316\n                    'connect_timeout' =&gt; 5.0\n                ]);\n            default:\n                throw new InvalidArgumentException('Unknown environment');\n        }\n    }\n}\n\n\/\/ \u74b0\u5883\u306b\u5fdc\u3058\u305f\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306e\u4f5c\u6210\n$config = GuzzleConfigFactory::createConfig(getenv('APP_ENV'));\n$client = new Client($config);<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-9\">4. \u3088\u304f\u4f7f\u7528\u3059\u308b\u8a2d\u5b9a\u30aa\u30d7\u30b7\u30e7\u30f3<\/h4>\n\n\n<div id=\"id-7d46c3e1-e26b-4cec-8137-7c911cf85513\">\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u30aa\u30d7\u30b7\u30e7\u30f3<\/th><th>\u8aac\u660e<\/th><th>\u63a8\u5968\u5024<\/th><\/tr><\/thead><tbody><tr><td>timeout<\/td><td>\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u6700\u5927\u5f85\u6a5f\u6642\u9593<\/td><td>5.0-30.0\u79d2<\/td><\/tr><tr><td>connect_timeout<\/td><td>\u63a5\u7d9a\u78ba\u7acb\u307e\u3067\u306e\u5f85\u6a5f\u6642\u9593<\/td><td>3.0-5.0\u79d2<\/td><\/tr><tr><td>http_errors<\/td><td>HTTP\u30a8\u30e9\u30fc\u3092\u4f8b\u5916\u3068\u3057\u3066\u6271\u3046\u304b<\/td><td>true<\/td><\/tr><tr><td>verify<\/td><td>SSL\u8a3c\u660e\u66f8\u306e\u691c\u8a3c<\/td><td>\u672c\u756a\u74b0\u5883: true<\/td><\/tr><tr><td>allow_redirects<\/td><td>\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u306e\u81ea\u52d5\u8ffd\u8de1<\/td><td>\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u8a2d\u5b9a<\/td><\/tr><tr><td>proxy<\/td><td>\u30d7\u30ed\u30ad\u30b7\u30b5\u30fc\u30d0\u30fc\u306e\u8a2d\u5b9a<\/td><td>\u74b0\u5883\u306b\u5fdc\u3058\u3066\u8a2d\u5b9a<\/td><\/tr><\/tbody><\/table><\/figure>\n<\/div>\n\n\n<p>\u3053\u308c\u3089\u306e\u57fa\u672c\u8a2d\u5b9a\u3092\u9069\u5207\u306b\u884c\u3046\u3053\u3068\u3067\u3001\u5f8c\u7d9a\u306e\u958b\u767a\u4f5c\u696d\u304c\u30b9\u30e0\u30fc\u30ba\u306b\u306a\u308a\u3001\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u6027\u306e\u9ad8\u3044\u30b3\u30fc\u30c9\u30d9\u30fc\u30b9\u3092\u7dad\u6301\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u3053\u308c\u3089\u306e\u57fa\u672c\u8a2d\u5b9a\u3092\u6d3b\u7528\u3057\u305f\u5177\u4f53\u7684\u306aHTTP\u30ea\u30af\u30a8\u30b9\u30c8\u51e6\u7406\u306e\u6539\u5584\u30c6\u30af\u30cb\u30c3\u30af\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-10\">HTTP\u30ea\u30af\u30a8\u30b9\u30c8\u51e6\u7406\u3092\u6539\u5584\u3059\u308b7\u3064\u306e\u30c6\u30af\u30cb\u30c3\u30af<\/h2>\n\n\n\n<p>Guzzle\u3092\u6d3b\u7528\u3057\u3066HTTP\u30ea\u30af\u30a8\u30b9\u30c8\u51e6\u7406\u3092\u6700\u9069\u5316\u3059\u308b\u3001\u5b9f\u8df5\u7684\u306a\u30c6\u30af\u30cb\u30c3\u30af\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002\u3053\u308c\u3089\u306e\u30c6\u30af\u30cb\u30c3\u30af\u3092\u9069\u5207\u306b\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001\u3088\u308a\u5805\u7262\u3067\u52b9\u7387\u7684\u306aAPI\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u3092\u5b9f\u88c5\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-11\">\u975e\u540c\u671f\u30ea\u30af\u30a8\u30b9\u30c8\u306b\u3088\u308b\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u5411\u4e0a<\/h3>\n\n\n\n<p>\u8907\u6570\u306eAPI\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u306b\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u9001\u4fe1\u3059\u308b\u5834\u5408\u3001\u975e\u540c\u671f\u51e6\u7406\u3092\u6d3b\u7528\u3059\u308b\u3053\u3068\u3067\u5927\u5e45\u306a\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u5411\u4e0a\u304c\u898b\u8fbc\u3081\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\nuse GuzzleHttp\\Client;\nuse GuzzleHttp\\Promise;\nuse GuzzleHttp\\Exception\\RequestException;\n\nclass AsyncRequestHandler\n{\n    private $client;\n\n    public function __construct()\n    {\n        $this-&gt;client = new Client([\n            'timeout' =&gt; 10,\n            'http_errors' =&gt; false\n        ]);\n    }\n\n    public function fetchMultipleEndpoints(array $endpoints)\n    {\n        \/\/ \u5404\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u306b\u5bfe\u3059\u308b\u975e\u540c\u671f\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u6e96\u5099\n        $promises = [];\n        foreach ($endpoints as $key =&gt; $url) {\n            $promises[$key] = $this-&gt;client-&gt;getAsync($url)-&gt;then(\n                function ($response) {\n                    return json_decode($response-&gt;getBody(), true);\n                },\n                function (RequestException $e) {\n                    return ['error' =&gt; $e-&gt;getMessage()];\n                }\n            );\n        }\n\n        \/\/ \u5168\u3066\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u4e26\u5217\u5b9f\u884c\n        return Promise\\Utils::settle($promises)-&gt;wait();\n    }\n}\n\n\/\/ \u4f7f\u7528\u4f8b\n$handler = new AsyncRequestHandler();\n$results = $handler-&gt;fetchMultipleEndpoints([\n    'users' =&gt; 'https:\/\/api.example.com\/users',\n    'posts' =&gt; 'https:\/\/api.example.com\/posts'\n]);<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-12\">\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u3092\u6d3b\u7528\u3057\u305f\u30ea\u30af\u30a8\u30b9\u30c8\/\u30ec\u30b9\u30dd\u30f3\u30b9\u51e6\u7406\u306e\u81ea\u52d5\u5316<\/h3>\n\n\n\n<p>\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u6a2a\u65ad\u7684\u306a\u51e6\u7406\u3092\u52b9\u7387\u7684\u306b\u5b9f\u88c5\u3067\u304d\u307e\u3059\u3002\u4ee5\u4e0b\u306f\u3001\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u30ed\u30b0\u8a18\u9332\u3068\u8a8d\u8a3c\u30c8\u30fc\u30af\u30f3\u306e\u81ea\u52d5\u4ed8\u4e0e\u3092\u884c\u3046\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u306e\u4f8b\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\nuse Psr\\Http\\Message\\RequestInterface;\nuse GuzzleHttp\\HandlerStack;\n\nclass RequestMiddleware\n{\n    private $logger;\n    private $tokenProvider;\n\n    public function __construct($logger, $tokenProvider)\n    {\n        $this-&gt;logger = $logger;\n        $this-&gt;tokenProvider = $tokenProvider;\n    }\n\n    public function __invoke(callable $handler)\n    {\n        return function (RequestInterface $request, array $options) use ($handler) {\n            \/\/ \u30ea\u30af\u30a8\u30b9\u30c8\u306e\u30ed\u30b0\u8a18\u9332\n            $this-&gt;logger-&gt;info('Outgoing request', [\n                'method' =&gt; $request-&gt;getMethod(),\n                'uri' =&gt; (string) $request-&gt;getUri()\n            ]);\n\n            \/\/ \u8a8d\u8a3c\u30c8\u30fc\u30af\u30f3\u306e\u4ed8\u4e0e\n            $request = $request-&gt;withHeader(\n                'Authorization',\n                'Bearer ' . $this-&gt;tokenProvider-&gt;getToken()\n            );\n\n            return $handler($request, $options);\n        };\n    }\n}\n\n\/\/ \u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u306e\u8a2d\u5b9a\n$stack = HandlerStack::create();\n$stack-&gt;push(new RequestMiddleware($logger, $tokenProvider));\n\n$client = new Client(['handler' =&gt; $stack]);<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-13\">\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u306e\u5b9f\u88c5\u3068\u30ea\u30c8\u30e9\u30a4\u6226\u7565<\/h3>\n\n\n\n<p>\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30a8\u30e9\u30fc\u3084\u4e00\u6642\u7684\u306a\u30b5\u30fc\u30d0\u30fc\u30a8\u30e9\u30fc\u306b\u5bfe\u3057\u3066\u3001\u9069\u5207\u306a\u30ea\u30c8\u30e9\u30a4\u6226\u7565\u3092\u5b9f\u88c5\u3059\u308b\u3053\u3068\u3067\u3001\u30b7\u30b9\u30c6\u30e0\u306e\u4fe1\u983c\u6027\u3092\u5411\u4e0a\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\nuse GuzzleHttp\\Middleware;\nuse GuzzleHttp\\Exception\\ConnectException;\nuse GuzzleHttp\\Exception\\ServerException;\n\nclass RetryableHttpClient\n{\n    private $client;\n\n    public function __construct()\n    {\n        $stack = HandlerStack::create();\n\n        \/\/ \u30ea\u30c8\u30e9\u30a4\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u306e\u8a2d\u5b9a\n        $stack-&gt;push(Middleware::retry(\n            function ($retries, $request, $response = null, $exception = null) {\n                \/\/ \u30ea\u30c8\u30e9\u30a4\u6761\u4ef6\u306e\u5b9a\u7fa9\n                if ($retries &gt;= 3) {\n                    return false;\n                }\n\n                if ($exception instanceof ConnectException) {\n                    return true; \/\/ \u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30a8\u30e9\u30fc\u306e\u5834\u5408\u306f\u30ea\u30c8\u30e9\u30a4\n                }\n\n                if ($response &amp;&amp; $response-&gt;getStatusCode() &gt;= 500) {\n                    return true; \/\/ \u30b5\u30fc\u30d0\u30fc\u30a8\u30e9\u30fc\u306e\u5834\u5408\u306f\u30ea\u30c8\u30e9\u30a4\n                }\n\n                return false;\n            },\n            function ($retries) {\n                \/\/ \u6307\u6570\u30d0\u30c3\u30af\u30aa\u30d5\u306b\u3088\u308b\u5f85\u6a5f\u6642\u9593\u306e\u8a2d\u5b9a\n                return min(1000 * pow(2, $retries), 10000);\n            }\n        ));\n\n        $this-&gt;client = new Client(['handler' =&gt; $stack]);\n    }\n\n    public function request($method, $uri, array $options = [])\n    {\n        try {\n            $response = $this-&gt;client-&gt;request($method, $uri, $options);\n            return json_decode($response-&gt;getBody(), true);\n        } catch (ServerException $e) {\n            \/\/ \u30ea\u30c8\u30e9\u30a4\u5f8c\u3082\u5931\u6557\u3057\u305f\u5834\u5408\u306e\u51e6\u7406\n            throw new ApiException('\u30ea\u30af\u30a8\u30b9\u30c8\u304c\u5931\u6557\u3057\u307e\u3057\u305f', 0, $e);\n        }\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-14\">\u8a8d\u8a3c\u51e6\u7406\u306e\u52b9\u7387\u7684\u306a\u5b9f\u88c5\u65b9\u6cd5<\/h3>\n\n\n\n<p>OAuth2.0\u306a\u3069\u306e\u8a8d\u8a3c\u30d5\u30ed\u30fc\u3092\u52b9\u7387\u7684\u306b\u5b9f\u88c5\u3059\u308b\u65b9\u6cd5\u3092\u793a\u3057\u307e\u3059\u3002\u30c8\u30fc\u30af\u30f3\u306e\u81ea\u52d5\u30ea\u30d5\u30ec\u30c3\u30b7\u30e5\u306a\u3069\u3082\u542b\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\nclass OAuth2Handler\n{\n    private $client;\n    private $tokenStorage;\n    private $clientId;\n    private $clientSecret;\n\n    public function __construct(\n        TokenStorageInterface $tokenStorage,\n        string $clientId,\n        string $clientSecret\n    ) {\n        $this-&gt;client = new Client();\n        $this-&gt;tokenStorage = $tokenStorage;\n        $this-&gt;clientId = $clientId;\n        $this-&gt;clientSecret = $clientSecret;\n    }\n\n    public function getAuthenticatedClient(): Client\n    {\n        $stack = HandlerStack::create();\n        $stack-&gt;push($this-&gt;getAuthMiddleware());\n\n        return new Client(['handler' =&gt; $stack]);\n    }\n\n    private function getAuthMiddleware()\n    {\n        return function (callable $handler) {\n            return function ($request, array $options) use ($handler) {\n                $token = $this-&gt;tokenStorage-&gt;getToken();\n\n                if ($token-&gt;isExpired()) {\n                    $token = $this-&gt;refreshToken($token);\n                    $this-&gt;tokenStorage-&gt;saveToken($token);\n                }\n\n                $request = $request-&gt;withHeader(\n                    'Authorization',\n                    'Bearer ' . $token-&gt;getAccessToken()\n                );\n\n                return $handler($request, $options);\n            };\n        };\n    }\n\n    private function refreshToken(TokenInterface $token)\n    {\n        $response = $this-&gt;client-&gt;post('https:\/\/auth.example.com\/token', [\n            'form_params' =&gt; [\n                'grant_type' =&gt; 'refresh_token',\n                'refresh_token' =&gt; $token-&gt;getRefreshToken(),\n                'client_id' =&gt; $this-&gt;clientId,\n                'client_secret' =&gt; $this-&gt;clientSecret,\n            ]\n        ]);\n\n        return Token::fromResponse($response);\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-15\">\u30ec\u30b9\u30dd\u30f3\u30b9\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u6226\u7565<\/h3>\n\n\n\n<p>\u983b\u7e41\u306b\u30a2\u30af\u30bb\u30b9\u3055\u308c\u308b\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u306e\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u30ad\u30e3\u30c3\u30b7\u30e5\u3059\u308b\u3053\u3068\u3067\u3001\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u5411\u4e0a\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\nuse Psr\\SimpleCache\\CacheInterface;\n\nclass CachingHttpClient\n{\n    private $client;\n    private $cache;\n    private $ttl;\n\n    public function __construct(\n        Client $client,\n        CacheInterface $cache,\n        int $ttl = 3600\n    ) {\n        $this-&gt;client = $client;\n        $this-&gt;cache = $cache;\n        $this-&gt;ttl = $ttl;\n    }\n\n    public function get(string $uri, array $options = [])\n    {\n        $cacheKey = $this-&gt;generateCacheKey($uri, $options);\n\n        if ($this-&gt;cache-&gt;has($cacheKey)) {\n            return $this-&gt;cache-&gt;get($cacheKey);\n        }\n\n        $response = $this-&gt;client-&gt;get($uri, $options);\n        $data = json_decode($response-&gt;getBody(), true);\n\n        $this-&gt;cache-&gt;set($cacheKey, $data, $this-&gt;ttl);\n\n        return $data;\n    }\n\n    private function generateCacheKey(string $uri, array $options): string\n    {\n        return md5($uri . serialize($options));\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-16\">\u30e2\u30c3\u30af\u3092\u4f7f\u7528\u3057\u305f\u30c6\u30b9\u30c8\u5b9f\u88c5<\/h3>\n\n\n\n<p>Guzzle\u306e\u30e2\u30c3\u30af\u6a5f\u80fd\u3092\u6d3b\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u5916\u90e8API\u306b\u4f9d\u5b58\u3057\u306a\u3044\u4fe1\u983c\u6027\u306e\u9ad8\u3044\u30c6\u30b9\u30c8\u3092\u5b9f\u88c5\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\nuse PHPUnit\\Framework\\TestCase;\nuse GuzzleHttp\\Handler\\MockHandler;\nuse GuzzleHttp\\Psr7\\Response;\n\nclass ApiClientTest extends TestCase\n{\n    private $client;\n    private $mockHandler;\n\n    protected function setUp(): void\n    {\n        $this-&gt;mockHandler = new MockHandler();\n        $stack = HandlerStack::create($this-&gt;mockHandler);\n        $this-&gt;client = new Client(['handler' =&gt; $stack]);\n    }\n\n    public function testSuccessfulApiCall()\n    {\n        \/\/ \u30e2\u30c3\u30af\u30ec\u30b9\u30dd\u30f3\u30b9\u306e\u8a2d\u5b9a\n        $this-&gt;mockHandler-&gt;append(\n            new Response(200, [], json_encode(['status' =&gt; 'success']))\n        );\n\n        $response = $this-&gt;client-&gt;get('\/api\/endpoint');\n        $data = json_decode($response-&gt;getBody(), true);\n\n        $this-&gt;assertEquals('success', $data['status']);\n    }\n\n    public function testErrorHandling()\n    {\n        $this-&gt;mockHandler-&gt;append(\n            new Response(500, [], json_encode(['error' =&gt; 'Server Error']))\n        );\n\n        $this-&gt;expectException(ServerException::class);\n        $this-&gt;client-&gt;get('\/api\/endpoint');\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-17\">\u5927\u898f\u6a21\u30b7\u30b9\u30c6\u30e0\u3067\u306eGuzzle\u30d7\u30fc\u30eb\u306e\u6d3b\u7528<\/h3>\n\n\n\n<p>\u5927\u91cf\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u52b9\u7387\u7684\u306b\u51e6\u7406\u3059\u308b\u305f\u3081\u306b\u3001Guzzle\u306e\u30d7\u30fc\u30eb\u6a5f\u80fd\u3092\u6d3b\u7528\u3059\u308b\u65b9\u6cd5\u3092\u793a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\nclass BatchRequestHandler\n{\n    private $client;\n    private $concurrency;\n\n    public function __construct(int $concurrency = 5)\n    {\n        $this-&gt;client = new Client();\n        $this-&gt;concurrency = $concurrency;\n    }\n\n    public function processBatch(array $urls): array\n    {\n        $results = [];\n        $errors = [];\n\n        $requests = function () use ($urls) {\n            foreach ($urls as $key =&gt; $url) {\n                yield $key =&gt; new Request('GET', $url);\n            }\n        };\n\n        $pool = new Pool($this-&gt;client, $requests(), [\n            'concurrency' =&gt; $this-&gt;concurrency,\n            'fulfilled' =&gt; function ($response, $key) use (&amp;$results) {\n                $results[$key] = json_decode($response-&gt;getBody(), true);\n            },\n            'rejected' =&gt; function ($reason, $key) use (&amp;$errors) {\n                $errors[$key] = $reason-&gt;getMessage();\n            }\n        ]);\n\n        $pool-&gt;promise()-&gt;wait();\n\n        return [\n            'results' =&gt; $results,\n            'errors' =&gt; $errors\n        ];\n    }\n}\n\n\/\/ \u4f7f\u7528\u4f8b\n$handler = new BatchRequestHandler(10);\n$result = $handler-&gt;processBatch([\n    'users' =&gt; 'https:\/\/api.example.com\/users',\n    'posts' =&gt; 'https:\/\/api.example.com\/posts',\n    'comments' =&gt; 'https:\/\/api.example.com\/comments'\n]);<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u30c6\u30af\u30cb\u30c3\u30af\u3092\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001\u3088\u308a\u5805\u7262\u3067\u52b9\u7387\u7684\u306aAPI\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u3092\u5b9f\u88c5\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u3053\u308c\u3089\u306e\u30c6\u30af\u30cb\u30c3\u30af\u3092\u6d3b\u7528\u3057\u305f\u5177\u4f53\u7684\u306a\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u3068\u5b9f\u88c5\u4f8b\u3092\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-18\">\u5b9f\u8df5\u7684\u306a\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u3068\u5b9f\u88c5\u4f8b<\/h2>\n\n\n\n<p>\u524d\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u7d39\u4ecb\u3057\u305f\u30c6\u30af\u30cb\u30c3\u30af\u3092\u5b9f\u969b\u306e\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u306b\u9069\u7528\u3059\u308b\u65b9\u6cd5\u3092\u3001\u5177\u4f53\u7684\u306a\u5b9f\u88c5\u4f8b\u3068\u3068\u3082\u306b\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-19\">REST API\u3068\u306e\u9023\u643a\u5b9f\u88c5<\/h3>\n\n\n\n<p>RESTful API\u3068\u306e\u52b9\u7387\u7684\u306a\u9023\u643a\u3092\u5b9f\u73fe\u3059\u308b\u5b9f\u88c5\u4f8b\u3092\u793a\u3057\u307e\u3059\u3002\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u306e\u62bd\u8c61\u5316\u3001\u30ea\u30bd\u30fc\u30b9\u306e\u53d6\u308a\u6271\u3044\u3001\u305d\u3057\u3066CRUD\u64cd\u4f5c\u306e\u5b9f\u88c5\u65b9\u6cd5\u3092\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\nnamespace App\\Services\\Api;\n\nuse GuzzleHttp\\Client;\nuse GuzzleHttp\\Exception\\GuzzleException;\n\nclass RestApiClient\n{\n    private $client;\n    private $baseUri;\n\n    public function __construct(string $baseUri)\n    {\n        $this-&gt;baseUri = $baseUri;\n        $this-&gt;client = new Client([\n            'base_uri' =&gt; $baseUri,\n            'timeout' =&gt; 30,\n            'headers' =&gt; [\n                'Accept' =&gt; 'application\/json',\n                'Content-Type' =&gt; 'application\/json'\n            ]\n        ]);\n    }\n\n    \/**\n     * \u30ea\u30bd\u30fc\u30b9\u306e\u53d6\u5f97\n     *\/\n    public function getResource(string $endpoint, array $queryParams = []): array\n    {\n        try {\n            $response = $this-&gt;client-&gt;get($endpoint, [\n                'query' =&gt; $queryParams\n            ]);\n\n            return json_decode($response-&gt;getBody(), true);\n        } catch (GuzzleException $e) {\n            $this-&gt;handleApiException($e);\n        }\n    }\n\n    \/**\n     * \u30ea\u30bd\u30fc\u30b9\u306e\u4f5c\u6210\n     *\/\n    public function createResource(string $endpoint, array $data): array\n    {\n        try {\n            $response = $this-&gt;client-&gt;post($endpoint, [\n                'json' =&gt; $data\n            ]);\n\n            return json_decode($response-&gt;getBody(), true);\n        } catch (GuzzleException $e) {\n            $this-&gt;handleApiException($e);\n        }\n    }\n\n    \/**\n     * \u30ea\u30bd\u30fc\u30b9\u306e\u66f4\u65b0\n     *\/\n    public function updateResource(string $endpoint, array $data): array\n    {\n        try {\n            $response = $this-&gt;client-&gt;put($endpoint, [\n                'json' =&gt; $data\n            ]);\n\n            return json_decode($response-&gt;getBody(), true);\n        } catch (GuzzleException $e) {\n            $this-&gt;handleApiException($e);\n        }\n    }\n\n    \/**\n     * \u30ea\u30bd\u30fc\u30b9\u306e\u524a\u9664\n     *\/\n    public function deleteResource(string $endpoint): bool\n    {\n        try {\n            $response = $this-&gt;client-&gt;delete($endpoint);\n            return $response-&gt;getStatusCode() === 204;\n        } catch (GuzzleException $e) {\n            $this-&gt;handleApiException($e);\n        }\n    }\n\n    \/**\n     * \u4e00\u62ec\u64cd\u4f5c\u306e\u5b9f\u88c5\n     *\/\n    public function batchOperation(array $operations): array\n    {\n        $promises = [];\n\n        foreach ($operations as $key =&gt; $operation) {\n            $method = strtolower($operation['method']);\n            $promises[$key] = $this-&gt;client-&gt;requestAsync(\n                $operation['method'],\n                $operation['endpoint'],\n                $operation['options'] ?? []\n            );\n        }\n\n        return \\GuzzleHttp\\Promise\\Utils::settle($promises)-&gt;wait();\n    }\n\n    private function handleApiException(GuzzleException $e)\n    {\n        \/\/ \u30a8\u30e9\u30fc\u30ec\u30b9\u30dd\u30f3\u30b9\u306e\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\n        if ($e instanceof RequestException &amp;&amp; $e-&gt;hasResponse()) {\n            $response = $e-&gt;getResponse();\n            $statusCode = $response-&gt;getStatusCode();\n            $error = json_decode($response-&gt;getBody(), true);\n\n            throw new ApiException(\n                $error['message'] ?? 'API error occurred',\n                $statusCode,\n                $e\n            );\n        }\n\n        throw new ApiException('API communication error', 0, $e);\n    }\n}\n\n\/\/ \u4f7f\u7528\u4f8b\n$apiClient = new RestApiClient('https:\/\/api.example.com\/v1\/');\n\n\/\/ \u30ea\u30bd\u30fc\u30b9\u306e\u53d6\u5f97\n$users = $apiClient-&gt;getResource('users', ['page' =&gt; 1, 'per_page' =&gt; 10]);\n\n\/\/ \u30ea\u30bd\u30fc\u30b9\u306e\u4f5c\u6210\n$newUser = $apiClient-&gt;createResource('users', [\n    'name' =&gt; 'John Doe',\n    'email' =&gt; 'john@example.com'\n]);\n\n\/\/ \u4e00\u62ec\u64cd\u4f5c\u306e\u5b9f\u884c\n$results = $apiClient-&gt;batchOperation([\n    'users' =&gt; [\n        'method' =&gt; 'GET',\n        'endpoint' =&gt; 'users'\n    ],\n    'posts' =&gt; [\n        'method' =&gt; 'GET',\n        'endpoint' =&gt; 'posts'\n    ]\n]);<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-20\">OAuth\u8a8d\u8a3c\u306e\u5b9f\u88c5\u30d1\u30bf\u30fc\u30f3<\/h3>\n\n\n\n<p>OAuth2.0\u8a8d\u8a3c\u3092\u4f7f\u7528\u3057\u305fAPI\u30a2\u30af\u30bb\u30b9\u306e\u5b9f\u88c5\u4f8b\u3092\u793a\u3057\u307e\u3059\u3002\u30c8\u30fc\u30af\u30f3\u306e\u7ba1\u7406\u3001\u81ea\u52d5\u30ea\u30d5\u30ec\u30c3\u30b7\u30e5\u3001\u305d\u3057\u3066\u72b6\u614b\u7ba1\u7406\u3092\u542b\u3081\u305f\u5305\u62ec\u7684\u306a\u5b9f\u88c5\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\nnamespace App\\Services\\Auth;\n\nuse GuzzleHttp\\Client;\nuse GuzzleHttp\\HandlerStack;\nuse Psr\\SimpleCache\\CacheInterface;\n\nclass OAuth2Client\n{\n    private $client;\n    private $cache;\n    private $config;\n\n    public function __construct(\n        array $config,\n        CacheInterface $cache\n    ) {\n        $this-&gt;config = $config;\n        $this-&gt;cache = $cache;\n\n        $stack = HandlerStack::create();\n        $stack-&gt;push($this-&gt;getAuthMiddleware());\n\n        $this-&gt;client = new Client([\n            'handler' =&gt; $stack,\n            'base_uri' =&gt; $config['api_url'],\n            'timeout' =&gt; 30\n        ]);\n    }\n\n    private function getAuthMiddleware()\n    {\n        return function (callable $handler) {\n            return function ($request, array $options) use ($handler) {\n                $token = $this-&gt;getValidToken();\n\n                return $handler(\n                    $request-&gt;withHeader('Authorization', \"Bearer {$token}\"),\n                    $options\n                );\n            };\n        };\n    }\n\n    private function getValidToken(): string\n    {\n        $cacheKey = 'oauth_token_' . md5($this-&gt;config['client_id']);\n\n        if ($token = $this-&gt;cache-&gt;get($cacheKey)) {\n            $tokenData = json_decode($token, true);\n\n            \/\/ \u30c8\u30fc\u30af\u30f3\u306e\u6709\u52b9\u671f\u9650\u30c1\u30a7\u30c3\u30af\uff08\u4f59\u88d5\u3092\u6301\u3063\u30665\u5206\u524d\u306b\u66f4\u65b0\uff09\n            if ($tokenData['expires_at'] &gt; time() + 300) {\n                return $tokenData['access_token'];\n            }\n        }\n\n        \/\/ \u65b0\u3057\u3044\u30c8\u30fc\u30af\u30f3\u306e\u53d6\u5f97\n        $tokenData = $this-&gt;fetchNewToken();\n\n        \/\/ \u30ad\u30e3\u30c3\u30b7\u30e5\u3078\u306e\u4fdd\u5b58\n        $this-&gt;cache-&gt;set($cacheKey, json_encode($tokenData), 3600);\n\n        return $tokenData['access_token'];\n    }\n\n    private function fetchNewToken(): array\n    {\n        $tokenClient = new Client();\n\n        $response = $tokenClient-&gt;post($this-&gt;config['token_url'], [\n            'form_params' =&gt; [\n                'grant_type' =&gt; 'client_credentials',\n                'client_id' =&gt; $this-&gt;config['client_id'],\n                'client_secret' =&gt; $this-&gt;config['client_secret'],\n                'scope' =&gt; $this-&gt;config['scope']\n            ]\n        ]);\n\n        $tokenData = json_decode($response-&gt;getBody(), true);\n        $tokenData['expires_at'] = time() + $tokenData['expires_in'];\n\n        return $tokenData;\n    }\n\n    public function request(string $method, string $uri, array $options = []): array\n    {\n        $response = $this-&gt;client-&gt;request($method, $uri, $options);\n        return json_decode($response-&gt;getBody(), true);\n    }\n}\n\n\/\/ \u4f7f\u7528\u4f8b\n$config = [\n    'api_url' =&gt; 'https:\/\/api.example.com\/v1\/',\n    'token_url' =&gt; 'https:\/\/auth.example.com\/oauth\/token',\n    'client_id' =&gt; 'your_client_id',\n    'client_secret' =&gt; 'your_client_secret',\n    'scope' =&gt; 'read write'\n];\n\n$oauthClient = new OAuth2Client($config, $cache);\n\n\/\/ \u8a8d\u8a3c\u6e08\u307f\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u5b9f\u884c\n$userData = $oauthClient-&gt;request('GET', 'user\/profile');<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-21\">Webhook\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/h3>\n\n\n\n<p>Webhook\u3092\u53d7\u4fe1\u3057\u51e6\u7406\u3059\u308b\u305f\u3081\u306e\u5b9f\u88c5\u4f8b\u3092\u793a\u3057\u307e\u3059\u3002\u30da\u30a4\u30ed\u30fc\u30c9\u306e\u691c\u8a3c\u3001\u975e\u540c\u671f\u51e6\u7406\u3001\u305d\u3057\u3066\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u3092\u542b\u3081\u305f\u5b9f\u88c5\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\nnamespace App\\Services\\Webhook;\n\nuse GuzzleHttp\\Client;\nuse Psr\\Log\\LoggerInterface;\n\nclass WebhookHandler\n{\n    private $client;\n    private $logger;\n    private $secret;\n\n    public function __construct(\n        Client $client,\n        LoggerInterface $logger,\n        string $secret\n    ) {\n        $this-&gt;client = $client;\n        $this-&gt;logger = $logger;\n        $this-&gt;secret = $secret;\n    }\n\n    public function handleWebhook(array $payload, string $signature): void\n    {\n        try {\n            \/\/ \u30b7\u30b0\u30cd\u30c1\u30e3\u306e\u691c\u8a3c\n            $this-&gt;verifySignature($payload, $signature);\n\n            \/\/ \u30da\u30a4\u30ed\u30fc\u30c9\u306e\u691c\u8a3c\n            $this-&gt;validatePayload($payload);\n\n            \/\/ \u30a4\u30d9\u30f3\u30c8\u306e\u7a2e\u985e\u306b\u5fdc\u3058\u305f\u51e6\u7406\n            $this-&gt;processWebhookEvent($payload);\n\n            \/\/ \u53d7\u4fe1\u78ba\u8a8d\u306e\u9001\u4fe1\n            $this-&gt;sendAcknowledgement($payload['id']);\n        } catch (\\Exception $e) {\n            $this-&gt;logger-&gt;error('Webhook processing failed', [\n                'error' =&gt; $e-&gt;getMessage(),\n                'payload' =&gt; $payload\n            ]);\n\n            throw $e;\n        }\n    }\n\n    private function verifySignature(array $payload, string $signature): void\n    {\n        $calculatedSignature = hash_hmac(\n            'sha256',\n            json_encode($payload),\n            $this-&gt;secret\n        );\n\n        if (!hash_equals($calculatedSignature, $signature)) {\n            throw new WebhookException('Invalid signature');\n        }\n    }\n\n    private function validatePayload(array $payload): void\n    {\n        $requiredFields = ['id', 'type', 'data'];\n\n        foreach ($requiredFields as $field) {\n            if (!isset($payload[$field])) {\n                throw new WebhookException(\"Missing required field: {$field}\");\n            }\n        }\n    }\n\n    private function processWebhookEvent(array $payload): void\n    {\n        switch ($payload['type']) {\n            case 'user.created':\n                $this-&gt;handleUserCreated($payload['data']);\n                break;\n            case 'user.updated':\n                $this-&gt;handleUserUpdated($payload['data']);\n                break;\n            case 'user.deleted':\n                $this-&gt;handleUserDeleted($payload['data']);\n                break;\n            default:\n                throw new WebhookException('Unknown event type');\n        }\n    }\n\n    private function sendAcknowledgement(string $webhookId): void\n    {\n        $this-&gt;client-&gt;post('https:\/\/api.sender.com\/webhook\/ack', [\n            'json' =&gt; [\n                'webhook_id' =&gt; $webhookId,\n                'status' =&gt; 'processed'\n            ]\n        ]);\n    }\n\n    private function handleUserCreated(array $userData): void\n    {\n        \/\/ \u975e\u540c\u671f\u30b8\u30e7\u30d6\u306e\u30c7\u30a3\u30b9\u30d1\u30c3\u30c1\n        dispatch(new ProcessUserCreatedJob($userData));\n    }\n\n    private function handleUserUpdated(array $userData): void\n    {\n        dispatch(new ProcessUserUpdatedJob($userData));\n    }\n\n    private function handleUserDeleted(array $userData): void\n    {\n        dispatch(new ProcessUserDeletedJob($userData));\n    }\n}\n\n\/\/ \u4f7f\u7528\u4f8b\n$webhookHandler = new WebhookHandler(\n    new Client(),\n    $logger,\n    'webhook_secret_key'\n);\n\n\/\/ Webhook\u306e\u51e6\u7406\n$webhookHandler-&gt;handleWebhook(\n    $_POST,\n    $_SERVER['HTTP_X_WEBHOOK_SIGNATURE']\n);<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u5b9f\u88c5\u4f8b\u306f\u3001\u5b9f\u969b\u306e\u958b\u767a\u73fe\u5834\u3067\u76f4\u9762\u3059\u308b\u5178\u578b\u7684\u306a\u8ab2\u984c\u306b\u5bfe\u3059\u308b\u89e3\u6c7a\u7b56\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u3053\u308c\u3089\u306e\u5b9f\u88c5\u3092\u3055\u3089\u306b\u6700\u9069\u5316\u3059\u308b\u305f\u3081\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-22\">\u5b9f\u8df5\u7684\u306a\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u3068\u5b9f\u88c5\u4f8b<\/h2>\n\n\n\n<p>\u524d\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u7d39\u4ecb\u3057\u305f\u30c6\u30af\u30cb\u30c3\u30af\u3092\u5b9f\u969b\u306e\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u306b\u9069\u7528\u3059\u308b\u65b9\u6cd5\u3092\u3001\u5177\u4f53\u7684\u306a\u5b9f\u88c5\u4f8b\u3068\u3068\u3082\u306b\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-23\">REST API\u3068\u306e\u9023\u643a\u5b9f\u88c5<\/h3>\n\n\n\n<p>RESTful API\u3068\u306e\u52b9\u7387\u7684\u306a\u9023\u643a\u3092\u5b9f\u73fe\u3059\u308b\u5b9f\u88c5\u4f8b\u3092\u793a\u3057\u307e\u3059\u3002\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u306e\u62bd\u8c61\u5316\u3001\u30ea\u30bd\u30fc\u30b9\u306e\u53d6\u308a\u6271\u3044\u3001\u305d\u3057\u3066CRUD\u64cd\u4f5c\u306e\u5b9f\u88c5\u65b9\u6cd5\u3092\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\nnamespace App\\Services\\Api;\n\nuse GuzzleHttp\\Client;\nuse GuzzleHttp\\Exception\\GuzzleException;\n\nclass RestApiClient\n{\n    private $client;\n    private $baseUri;\n\n    public function __construct(string $baseUri)\n    {\n        $this-&gt;baseUri = $baseUri;\n        $this-&gt;client = new Client([\n            'base_uri' =&gt; $baseUri,\n            'timeout' =&gt; 30,\n            'headers' =&gt; [\n                'Accept' =&gt; 'application\/json',\n                'Content-Type' =&gt; 'application\/json'\n            ]\n        ]);\n    }\n\n    \/**\n     * \u30ea\u30bd\u30fc\u30b9\u306e\u53d6\u5f97\n     *\/\n    public function getResource(string $endpoint, array $queryParams = []): array\n    {\n        try {\n            $response = $this-&gt;client-&gt;get($endpoint, [\n                'query' =&gt; $queryParams\n            ]);\n\n            return json_decode($response-&gt;getBody(), true);\n        } catch (GuzzleException $e) {\n            $this-&gt;handleApiException($e);\n        }\n    }\n\n    \/**\n     * \u30ea\u30bd\u30fc\u30b9\u306e\u4f5c\u6210\n     *\/\n    public function createResource(string $endpoint, array $data): array\n    {\n        try {\n            $response = $this-&gt;client-&gt;post($endpoint, [\n                'json' =&gt; $data\n            ]);\n\n            return json_decode($response-&gt;getBody(), true);\n        } catch (GuzzleException $e) {\n            $this-&gt;handleApiException($e);\n        }\n    }\n\n    \/**\n     * \u30ea\u30bd\u30fc\u30b9\u306e\u66f4\u65b0\n     *\/\n    public function updateResource(string $endpoint, array $data): array\n    {\n        try {\n            $response = $this-&gt;client-&gt;put($endpoint, [\n                'json' =&gt; $data\n            ]);\n\n            return json_decode($response-&gt;getBody(), true);\n        } catch (GuzzleException $e) {\n            $this-&gt;handleApiException($e);\n        }\n    }\n\n    \/**\n     * \u30ea\u30bd\u30fc\u30b9\u306e\u524a\u9664\n     *\/\n    public function deleteResource(string $endpoint): bool\n    {\n        try {\n            $response = $this-&gt;client-&gt;delete($endpoint);\n            return $response-&gt;getStatusCode() === 204;\n        } catch (GuzzleException $e) {\n            $this-&gt;handleApiException($e);\n        }\n    }\n\n    \/**\n     * \u4e00\u62ec\u64cd\u4f5c\u306e\u5b9f\u88c5\n     *\/\n    public function batchOperation(array $operations): array\n    {\n        $promises = [];\n\n        foreach ($operations as $key =&gt; $operation) {\n            $method = strtolower($operation['method']);\n            $promises[$key] = $this-&gt;client-&gt;requestAsync(\n                $operation['method'],\n                $operation['endpoint'],\n                $operation['options'] ?? []\n            );\n        }\n\n        return \\GuzzleHttp\\Promise\\Utils::settle($promises)-&gt;wait();\n    }\n\n    private function handleApiException(GuzzleException $e)\n    {\n        \/\/ \u30a8\u30e9\u30fc\u30ec\u30b9\u30dd\u30f3\u30b9\u306e\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\n        if ($e instanceof RequestException &amp;&amp; $e-&gt;hasResponse()) {\n            $response = $e-&gt;getResponse();\n            $statusCode = $response-&gt;getStatusCode();\n            $error = json_decode($response-&gt;getBody(), true);\n\n            throw new ApiException(\n                $error['message'] ?? 'API error occurred',\n                $statusCode,\n                $e\n            );\n        }\n\n        throw new ApiException('API communication error', 0, $e);\n    }\n}\n\n\/\/ \u4f7f\u7528\u4f8b\n$apiClient = new RestApiClient('https:\/\/api.example.com\/v1\/');\n\n\/\/ \u30ea\u30bd\u30fc\u30b9\u306e\u53d6\u5f97\n$users = $apiClient-&gt;getResource('users', ['page' =&gt; 1, 'per_page' =&gt; 10]);\n\n\/\/ \u30ea\u30bd\u30fc\u30b9\u306e\u4f5c\u6210\n$newUser = $apiClient-&gt;createResource('users', [\n    'name' =&gt; 'John Doe',\n    'email' =&gt; 'john@example.com'\n]);\n\n\/\/ \u4e00\u62ec\u64cd\u4f5c\u306e\u5b9f\u884c\n$results = $apiClient-&gt;batchOperation([\n    'users' =&gt; [\n        'method' =&gt; 'GET',\n        'endpoint' =&gt; 'users'\n    ],\n    'posts' =&gt; [\n        'method' =&gt; 'GET',\n        'endpoint' =&gt; 'posts'\n    ]\n]);<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-24\">OAuth\u8a8d\u8a3c\u306e\u5b9f\u88c5\u30d1\u30bf\u30fc\u30f3<\/h3>\n\n\n\n<p>OAuth2.0\u8a8d\u8a3c\u3092\u4f7f\u7528\u3057\u305fAPI\u30a2\u30af\u30bb\u30b9\u306e\u5b9f\u88c5\u4f8b\u3092\u793a\u3057\u307e\u3059\u3002\u30c8\u30fc\u30af\u30f3\u306e\u7ba1\u7406\u3001\u81ea\u52d5\u30ea\u30d5\u30ec\u30c3\u30b7\u30e5\u3001\u305d\u3057\u3066\u72b6\u614b\u7ba1\u7406\u3092\u542b\u3081\u305f\u5305\u62ec\u7684\u306a\u5b9f\u88c5\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\nnamespace App\\Services\\Auth;\n\nuse GuzzleHttp\\Client;\nuse GuzzleHttp\\HandlerStack;\nuse Psr\\SimpleCache\\CacheInterface;\n\nclass OAuth2Client\n{\n    private $client;\n    private $cache;\n    private $config;\n\n    public function __construct(\n        array $config,\n        CacheInterface $cache\n    ) {\n        $this-&gt;config = $config;\n        $this-&gt;cache = $cache;\n\n        $stack = HandlerStack::create();\n        $stack-&gt;push($this-&gt;getAuthMiddleware());\n\n        $this-&gt;client = new Client([\n            'handler' =&gt; $stack,\n            'base_uri' =&gt; $config['api_url'],\n            'timeout' =&gt; 30\n        ]);\n    }\n\n    private function getAuthMiddleware()\n    {\n        return function (callable $handler) {\n            return function ($request, array $options) use ($handler) {\n                $token = $this-&gt;getValidToken();\n\n                return $handler(\n                    $request-&gt;withHeader('Authorization', \"Bearer {$token}\"),\n                    $options\n                );\n            };\n        };\n    }\n\n    private function getValidToken(): string\n    {\n        $cacheKey = 'oauth_token_' . md5($this-&gt;config['client_id']);\n\n        if ($token = $this-&gt;cache-&gt;get($cacheKey)) {\n            $tokenData = json_decode($token, true);\n\n            \/\/ \u30c8\u30fc\u30af\u30f3\u306e\u6709\u52b9\u671f\u9650\u30c1\u30a7\u30c3\u30af\uff08\u4f59\u88d5\u3092\u6301\u3063\u30665\u5206\u524d\u306b\u66f4\u65b0\uff09\n            if ($tokenData['expires_at'] &gt; time() + 300) {\n                return $tokenData['access_token'];\n            }\n        }\n\n        \/\/ \u65b0\u3057\u3044\u30c8\u30fc\u30af\u30f3\u306e\u53d6\u5f97\n        $tokenData = $this-&gt;fetchNewToken();\n\n        \/\/ \u30ad\u30e3\u30c3\u30b7\u30e5\u3078\u306e\u4fdd\u5b58\n        $this-&gt;cache-&gt;set($cacheKey, json_encode($tokenData), 3600);\n\n        return $tokenData['access_token'];\n    }\n\n    private function fetchNewToken(): array\n    {\n        $tokenClient = new Client();\n\n        $response = $tokenClient-&gt;post($this-&gt;config['token_url'], [\n            'form_params' =&gt; [\n                'grant_type' =&gt; 'client_credentials',\n                'client_id' =&gt; $this-&gt;config['client_id'],\n                'client_secret' =&gt; $this-&gt;config['client_secret'],\n                'scope' =&gt; $this-&gt;config['scope']\n            ]\n        ]);\n\n        $tokenData = json_decode($response-&gt;getBody(), true);\n        $tokenData['expires_at'] = time() + $tokenData['expires_in'];\n\n        return $tokenData;\n    }\n\n    public function request(string $method, string $uri, array $options = []): array\n    {\n        $response = $this-&gt;client-&gt;request($method, $uri, $options);\n        return json_decode($response-&gt;getBody(), true);\n    }\n}\n\n\/\/ \u4f7f\u7528\u4f8b\n$config = [\n    'api_url' =&gt; 'https:\/\/api.example.com\/v1\/',\n    'token_url' =&gt; 'https:\/\/auth.example.com\/oauth\/token',\n    'client_id' =&gt; 'your_client_id',\n    'client_secret' =&gt; 'your_client_secret',\n    'scope' =&gt; 'read write'\n];\n\n$oauthClient = new OAuth2Client($config, $cache);\n\n\/\/ \u8a8d\u8a3c\u6e08\u307f\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u5b9f\u884c\n$userData = $oauthClient-&gt;request('GET', 'user\/profile');<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-25\">Webhook\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/h3>\n\n\n\n<p>Webhook\u3092\u53d7\u4fe1\u3057\u51e6\u7406\u3059\u308b\u305f\u3081\u306e\u5b9f\u88c5\u4f8b\u3092\u793a\u3057\u307e\u3059\u3002\u30da\u30a4\u30ed\u30fc\u30c9\u306e\u691c\u8a3c\u3001\u975e\u540c\u671f\u51e6\u7406\u3001\u305d\u3057\u3066\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u3092\u542b\u3081\u305f\u5b9f\u88c5\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\nnamespace App\\Services\\Webhook;\n\nuse GuzzleHttp\\Client;\nuse Psr\\Log\\LoggerInterface;\n\nclass WebhookHandler\n{\n    private $client;\n    private $logger;\n    private $secret;\n\n    public function __construct(\n        Client $client,\n        LoggerInterface $logger,\n        string $secret\n    ) {\n        $this-&gt;client = $client;\n        $this-&gt;logger = $logger;\n        $this-&gt;secret = $secret;\n    }\n\n    public function handleWebhook(array $payload, string $signature): void\n    {\n        try {\n            \/\/ \u30b7\u30b0\u30cd\u30c1\u30e3\u306e\u691c\u8a3c\n            $this-&gt;verifySignature($payload, $signature);\n\n            \/\/ \u30da\u30a4\u30ed\u30fc\u30c9\u306e\u691c\u8a3c\n            $this-&gt;validatePayload($payload);\n\n            \/\/ \u30a4\u30d9\u30f3\u30c8\u306e\u7a2e\u985e\u306b\u5fdc\u3058\u305f\u51e6\u7406\n            $this-&gt;processWebhookEvent($payload);\n\n            \/\/ \u53d7\u4fe1\u78ba\u8a8d\u306e\u9001\u4fe1\n            $this-&gt;sendAcknowledgement($payload['id']);\n        } catch (\\Exception $e) {\n            $this-&gt;logger-&gt;error('Webhook processing failed', [\n                'error' =&gt; $e-&gt;getMessage(),\n                'payload' =&gt; $payload\n            ]);\n\n            throw $e;\n        }\n    }\n\n    private function verifySignature(array $payload, string $signature): void\n    {\n        $calculatedSignature = hash_hmac(\n            'sha256',\n            json_encode($payload),\n            $this-&gt;secret\n        );\n\n        if (!hash_equals($calculatedSignature, $signature)) {\n            throw new WebhookException('Invalid signature');\n        }\n    }\n\n    private function validatePayload(array $payload): void\n    {\n        $requiredFields = ['id', 'type', 'data'];\n\n        foreach ($requiredFields as $field) {\n            if (!isset($payload[$field])) {\n                throw new WebhookException(\"Missing required field: {$field}\");\n            }\n        }\n    }\n\n    private function processWebhookEvent(array $payload): void\n    {\n        switch ($payload['type']) {\n            case 'user.created':\n                $this-&gt;handleUserCreated($payload['data']);\n                break;\n            case 'user.updated':\n                $this-&gt;handleUserUpdated($payload['data']);\n                break;\n            case 'user.deleted':\n                $this-&gt;handleUserDeleted($payload['data']);\n                break;\n            default:\n                throw new WebhookException('Unknown event type');\n        }\n    }\n\n    private function sendAcknowledgement(string $webhookId): void\n    {\n        $this-&gt;client-&gt;post('https:\/\/api.sender.com\/webhook\/ack', [\n            'json' =&gt; [\n                'webhook_id' =&gt; $webhookId,\n                'status' =&gt; 'processed'\n            ]\n        ]);\n    }\n\n    private function handleUserCreated(array $userData): void\n    {\n        \/\/ \u975e\u540c\u671f\u30b8\u30e7\u30d6\u306e\u30c7\u30a3\u30b9\u30d1\u30c3\u30c1\n        dispatch(new ProcessUserCreatedJob($userData));\n    }\n\n    private function handleUserUpdated(array $userData): void\n    {\n        dispatch(new ProcessUserUpdatedJob($userData));\n    }\n\n    private function handleUserDeleted(array $userData): void\n    {\n        dispatch(new ProcessUserDeletedJob($userData));\n    }\n}\n\n\/\/ \u4f7f\u7528\u4f8b\n$webhookHandler = new WebhookHandler(\n    new Client(),\n    $logger,\n    'webhook_secret_key'\n);\n\n\/\/ Webhook\u306e\u51e6\u7406\n$webhookHandler-&gt;handleWebhook(\n    $_POST,\n    $_SERVER['HTTP_X_WEBHOOK_SIGNATURE']\n);<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u5b9f\u88c5\u4f8b\u306f\u3001\u5b9f\u969b\u306e\u958b\u767a\u73fe\u5834\u3067\u76f4\u9762\u3059\u308b\u5178\u578b\u7684\u306a\u8ab2\u984c\u306b\u5bfe\u3059\u308b\u89e3\u6c7a\u7b56\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u3053\u308c\u3089\u306e\u5b9f\u88c5\u3092\u3055\u3089\u306b\u6700\u9069\u5316\u3059\u308b\u305f\u3081\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-26\">Guzzle\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0<\/h2>\n\n\n\n<p>Guzzle\u3092\u672c\u756a\u74b0\u5883\u3067\u52b9\u7387\u7684\u306b\u904b\u7528\u3059\u308b\u305f\u3081\u306b\u306f\u3001\u9069\u5207\u306a\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0\u304c\u4e0d\u53ef\u6b20\u3067\u3059\u3002\u3053\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u306e\u6700\u9069\u5316\u304b\u3089\u540c\u6642\u63a5\u7d9a\u6570\u306e\u8a2d\u5b9a\u307e\u3067\u3001\u5b9f\u8df5\u7684\u306a\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0\u624b\u6cd5\u3092\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-27\">\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u306e\u6700\u9069\u5316\u30c6\u30af\u30cb\u30c3\u30af<\/h3>\n\n\n\n<p>\u5927\u91cf\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u51e6\u7406\u3059\u308b\u5834\u5408\u3084\u3001\u5927\u304d\u306a\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u6271\u3046\u5834\u5408\u306e\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u3092\u6700\u9069\u5316\u3059\u308b\u65b9\u6cd5\u3092\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\nnamespace App\\Services\\Http;\n\nuse GuzzleHttp\\Client;\nuse GuzzleHttp\\Psr7\\StreamWrapper;\nuse Psr\\Http\\Message\\ResponseInterface;\n\nclass OptimizedHttpClient\n{\n    private $client;\n\n    public function __construct()\n    {\n        $this-&gt;client = new Client([\n            'timeout' =&gt; 30,\n            'connect_timeout' =&gt; 5,\n            'http_errors' =&gt; false\n        ]);\n    }\n\n    \/**\n     * \u5927\u304d\u306a\u30d5\u30a1\u30a4\u30eb\u3092\u30b9\u30c8\u30ea\u30fc\u30df\u30f3\u30b0\u3067\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\n     *\/\n    public function downloadLargeFile(string $url, string $destinationPath): void\n    {\n        $response = $this-&gt;client-&gt;get($url, ['stream' =&gt; true]);\n\n        \/\/ \u30ec\u30b9\u30dd\u30f3\u30b9\u30dc\u30c7\u30a3\u3092\u30b9\u30c8\u30ea\u30fc\u30e0\u3068\u3057\u3066\u53d6\u5f97\n        $body = $response-&gt;getBody();\n\n        \/\/ \u30d5\u30a1\u30a4\u30eb\u306b\u76f4\u63a5\u30b9\u30c8\u30ea\u30fc\u30e0\n        $handle = fopen($destinationPath, 'wb');\n\n        \/\/ 1MB\u305a\u3064\u8aad\u307f\u8fbc\u3093\u3067\u66f8\u304d\u8fbc\u307f\n        while (!$body-&gt;eof()) {\n            fwrite($handle, $body-&gt;read(1024 * 1024));\n        }\n\n        fclose($handle);\n        $body-&gt;close();\n    }\n\n    \/**\n     * \u5927\u304d\u306aJSON\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u5c11\u3057\u305a\u3064\u51e6\u7406\n     *\/\n    public function processLargeJsonResponse(\n        string $url,\n        callable $itemProcessor\n    ): void {\n        $response = $this-&gt;client-&gt;get($url, [\n            'stream' =&gt; true,\n            'headers' =&gt; ['Accept' =&gt; 'application\/json']\n        ]);\n\n        \/\/ JSON\u30b9\u30c8\u30ea\u30fc\u30e0\u30d1\u30fc\u30b5\u30fc\u306e\u521d\u671f\u5316\n        $parser = new \\JsonStreamingParser\\Parser(\n            StreamWrapper::getResource($response-&gt;getBody()),\n            new class($itemProcessor) implements \\JsonStreamingParser\\Listener {\n                private $itemProcessor;\n                private $buffer = [];\n\n                public function __construct(callable $itemProcessor)\n                {\n                    $this-&gt;itemProcessor = $itemProcessor;\n                }\n\n                public function value($value): void\n                {\n                    $this-&gt;buffer[] = $value;\n\n                    \/\/ \u30d0\u30c3\u30d5\u30a1\u304c\u4e00\u5b9a\u30b5\u30a4\u30ba\u306b\u306a\u3063\u305f\u3089\u51e6\u7406\n                    if (count($this-&gt;buffer) &gt;= 100) {\n                        $this-&gt;flush();\n                    }\n                }\n\n                private function flush(): void\n                {\n                    ($this-&gt;itemProcessor)($this-&gt;buffer);\n                    $this-&gt;buffer = [];\n                }\n            }\n        );\n\n        $parser-&gt;parse();\n    }\n\n    \/**\n     * \u30e1\u30e2\u30ea\u52b9\u7387\u306e\u826f\u3044\u30d0\u30c3\u30c1\u51e6\u7406\n     *\/\n    public function batchProcessUrls(array $urls): \\Generator\n    {\n        $batchSize = 10;\n        $urlBatches = array_chunk($urls, $batchSize);\n\n        foreach ($urlBatches as $batch) {\n            $promises = [];\n\n            foreach ($batch as $url) {\n                $promises[$url] = $this-&gt;client-&gt;getAsync($url);\n            }\n\n            $responses = \\GuzzleHttp\\Promise\\Utils::settle($promises)-&gt;wait();\n\n            foreach ($responses as $url =&gt; $result) {\n                yield $url =&gt; $result;\n            }\n\n            \/\/ \u30e1\u30e2\u30ea\u89e3\u653e\n            unset($promises, $responses);\n            gc_collect_cycles();\n        }\n    }\n}\n\n\/\/ \u30e1\u30e2\u30ea\u6700\u9069\u5316\u306e\u4f7f\u7528\u4f8b\n$client = new OptimizedHttpClient();\n\n\/\/ \u5927\u304d\u306a\u30d5\u30a1\u30a4\u30eb\u306e\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\n$client-&gt;downloadLargeFile(\n    'https:\/\/example.com\/large-file.zip',\n    '\/tmp\/downloaded-file.zip'\n);\n\n\/\/ \u5927\u304d\u306aJSON\u30ec\u30b9\u30dd\u30f3\u30b9\u306e\u51e6\u7406\n$client-&gt;processLargeJsonResponse(\n    'https:\/\/api.example.com\/large-dataset',\n    function (array $items) {\n        foreach ($items as $item) {\n            \/\/ \u5404\u30a2\u30a4\u30c6\u30e0\u306e\u51e6\u7406\n            processItem($item);\n        }\n    }\n);\n\n\/\/ \u30d0\u30c3\u30c1\u51e6\u7406\nforeach ($client-&gt;batchProcessUrls($urls) as $url =&gt; $result) {\n    if ($result['state'] === 'fulfilled') {\n        processSuccess($url, $result['value']);\n    } else {\n        processError($url, $result['reason']);\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-28\">\u540c\u6642\u63a5\u7d9a\u6570\u306e\u9069\u5207\u306a\u8a2d\u5b9a\u65b9\u6cd5<\/h3>\n\n\n\n<p>\u30b7\u30b9\u30c6\u30e0\u30ea\u30bd\u30fc\u30b9\u3068\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u30d0\u30e9\u30f3\u30b9\u3092\u53d6\u308b\u305f\u3081\u306e\u3001\u540c\u6642\u63a5\u7d9a\u6570\u306e\u6700\u9069\u306a\u8a2d\u5b9a\u65b9\u6cd5\u3092\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\nnamespace App\\Services\\Http;\n\nuse GuzzleHttp\\Client;\nuse GuzzleHttp\\Pool;\nuse GuzzleHttp\\Psr7\\Request;\nuse Psr\\Log\\LoggerInterface;\n\nclass ConnectionPoolManager\n{\n    private $client;\n    private $logger;\n    private $metrics;\n\n    \/\/ \u30b7\u30b9\u30c6\u30e0\u30ea\u30bd\u30fc\u30b9\u306b\u57fa\u3065\u304f\u8a2d\u5b9a\u5024\n    private const DEFAULT_CONCURRENCY = 25;\n    private const MAX_CONCURRENCY = 50;\n    private const MIN_CONCURRENCY = 5;\n\n    public function __construct(\n        LoggerInterface $logger,\n        MetricsCollectorInterface $metrics\n    ) {\n        $this-&gt;logger = $logger;\n        $this-&gt;metrics = $metrics;\n\n        $this-&gt;client = new Client([\n            'timeout' =&gt; 30,\n            'connect_timeout' =&gt; 5,\n            'http_errors' =&gt; false\n        ]);\n    }\n\n    \/**\n     * \u30b7\u30b9\u30c6\u30e0\u30ea\u30bd\u30fc\u30b9\u306b\u57fa\u3065\u3044\u3066\u540c\u6642\u63a5\u7d9a\u6570\u3092\u52d5\u7684\u306b\u8abf\u6574\n     *\/\n    private function determineOptimalConcurrency(): int\n    {\n        $systemLoad = sys_getloadavg()[0];\n        $memoryUsage = memory_get_usage(true) \/ memory_get_peak_usage(true);\n\n        \/\/ \u30b7\u30b9\u30c6\u30e0\u8ca0\u8377\u304c\u9ad8\u3044\u5834\u5408\u306f\u63a5\u7d9a\u6570\u3092\u6e1b\u3089\u3059\n        if ($systemLoad &gt; 0.8) {\n            return self::MIN_CONCURRENCY;\n        }\n\n        \/\/ \u30e1\u30e2\u30ea\u4f7f\u7528\u7387\u304c\u9ad8\u3044\u5834\u5408\u306f\u63a5\u7d9a\u6570\u3092\u5236\u9650\n        if ($memoryUsage &gt; 0.7) {\n            return self::MIN_CONCURRENCY;\n        }\n\n        \/\/ \u901a\u5e38\u6642\u306f\u6a19\u6e96\u8a2d\u5b9a\u3092\u4f7f\u7528\n        return self::DEFAULT_CONCURRENCY;\n    }\n\n    \/**\n     * \u9069\u5fdc\u7684\u306a\u540c\u6642\u5b9f\u884c\u5236\u5fa1\u3092\u884c\u3046\u30d0\u30c3\u30c1\u51e6\u7406\n     *\/\n    public function processWithAdaptiveConcurrency(array $requests): array\n    {\n        $results = [];\n        $errors = [];\n        $concurrency = $this-&gt;determineOptimalConcurrency();\n\n        $pool = new Pool($this-&gt;client, $requests, [\n            'concurrency' =&gt; $concurrency,\n            'fulfilled' =&gt; function ($response, $index) use (&amp;$results) {\n                $results[$index] = json_decode($response-&gt;getBody(), true);\n\n                \/\/ \u30e1\u30c8\u30ea\u30af\u30b9\u306e\u8a18\u9332\n                $this-&gt;metrics-&gt;recordResponseTime(\n                    $response-&gt;getHeaderLine('X-Response-Time')\n                );\n            },\n            'rejected' =&gt; function ($reason, $index) use (&amp;$errors) {\n                $errors[$index] = $reason-&gt;getMessage();\n\n                \/\/ \u30a8\u30e9\u30fc\u30e1\u30c8\u30ea\u30af\u30b9\u306e\u8a18\u9332\n                $this-&gt;metrics-&gt;incrementErrorCount();\n\n                $this-&gt;logger-&gt;error('Request failed', [\n                    'index' =&gt; $index,\n                    'error' =&gt; $reason-&gt;getMessage()\n                ]);\n            }\n        ]);\n\n        \/\/ \u30d7\u30fc\u30eb\u306e\u5b9f\u884c\u3092\u5f85\u6a5f\n        $pool-&gt;promise()-&gt;wait();\n\n        return [\n            'results' =&gt; $results,\n            'errors' =&gt; $errors,\n            'concurrency' =&gt; $concurrency\n        ];\n    }\n\n    \/**\n     * \u63a5\u7d9a\u30d7\u30fc\u30eb\u306e\u72b6\u614b\u76e3\u8996\n     *\/\n    public function getPoolMetrics(): array\n    {\n        return [\n            'current_concurrency' =&gt; $this-&gt;determineOptimalConcurrency(),\n            'active_connections' =&gt; $this-&gt;metrics-&gt;getActiveConnections(),\n            'average_response_time' =&gt; $this-&gt;metrics-&gt;getAverageResponseTime(),\n            'error_rate' =&gt; $this-&gt;metrics-&gt;getErrorRate(),\n            'system_load' =&gt; sys_getloadavg()[0]\n        ];\n    }\n\n    \/**\n     * \u63a5\u7d9a\u30d7\u30fc\u30eb\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u30c6\u30b9\u30c8\n     *\/\n    public function runPerformanceTest(\n        array $endpoints,\n        int $iterations = 100\n    ): array {\n        $results = [];\n        $startTime = microtime(true);\n\n        for ($i = 0; $i &lt; $iterations; $i++) {\n            $requests = array_map(function ($endpoint) {\n                return new Request('GET', $endpoint);\n            }, $endpoints);\n\n            $batchResults = $this-&gt;processWithAdaptiveConcurrency($requests);\n            $results[] = $batchResults;\n\n            \/\/ \u77ed\u3044\u5f85\u6a5f\u6642\u9593\u3092\u8a2d\u5b9a\u3057\u3066\u30b7\u30b9\u30c6\u30e0\u306e\u56de\u5fa9\u3092\u8a31\u53ef\n            usleep(100000); \/\/ 0.1\u79d2\n        }\n\n        $duration = microtime(true) - $startTime;\n\n        return [\n            'total_requests' =&gt; $iterations * count($endpoints),\n            'total_duration' =&gt; $duration,\n            'requests_per_second' =&gt; ($iterations * count($endpoints)) \/ $duration,\n            'average_concurrency' =&gt; array_sum(array_column($results, 'concurrency')) \/ count($results),\n            'error_rate' =&gt; $this-&gt;metrics-&gt;getErrorRate()\n        ];\n    }\n}\n\n\/\/ \u4f7f\u7528\u4f8b\n$poolManager = new ConnectionPoolManager($logger, $metrics);\n\n\/\/ \u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u306e\u6e96\u5099\n$endpoints = [\n    'https:\/\/api1.example.com\/data',\n    'https:\/\/api2.example.com\/data',\n    'https:\/\/api3.example.com\/data'\n];\n\n\/\/ \u30ea\u30af\u30a8\u30b9\u30c8\u306e\u4f5c\u6210\n$requests = array_map(function ($endpoint) {\n    return new Request('GET', $endpoint);\n}, $endpoints);\n\n\/\/ \u9069\u5fdc\u7684\u306a\u540c\u6642\u5b9f\u884c\u5236\u5fa1\u3092\u4f7f\u7528\u3057\u3066\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u51e6\u7406\n$results = $poolManager-&gt;processWithAdaptiveConcurrency($requests);\n\n\/\/ \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u30e1\u30c8\u30ea\u30af\u30b9\u306e\u53d6\u5f97\n$metrics = $poolManager-&gt;getPoolMetrics();\n\n\/\/ \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u30c6\u30b9\u30c8\u306e\u5b9f\u884c\n$testResults = $poolManager-&gt;runPerformanceTest($endpoints, 100);<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u6700\u9069\u5316\u30c6\u30af\u30cb\u30c3\u30af\u3092\u9069\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u52b9\u679c\u304c\u671f\u5f85\u3067\u304d\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u306e\u524a\u6e1b<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30b9\u30c8\u30ea\u30fc\u30df\u30f3\u30b0\u51e6\u7406\u306b\u3088\u308b\u5927\u304d\u306a\u30ec\u30b9\u30dd\u30f3\u30b9\u306e\u52b9\u7387\u7684\u306a\u51e6\u7406<\/li>\n\n\n\n<li>\u4e0d\u8981\u306a\u30e1\u30e2\u30ea\u306e\u65e9\u671f\u89e3\u653e<\/li>\n\n\n\n<li>\u30d0\u30c3\u30c1\u51e6\u7406\u6642\u306e\u30e1\u30e2\u30ea\u7ba1\u7406\u306e\u6700\u9069\u5316<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30b7\u30b9\u30c6\u30e0\u30ea\u30bd\u30fc\u30b9\u306e\u52b9\u7387\u7684\u306a\u5229\u7528<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30b7\u30b9\u30c6\u30e0\u8ca0\u8377\u306b\u5fdc\u3058\u305f\u52d5\u7684\u306a\u540c\u6642\u63a5\u7d9a\u6570\u306e\u8abf\u6574<\/li>\n\n\n\n<li>\u52b9\u7387\u7684\u306a\u30b3\u30cd\u30af\u30b7\u30e7\u30f3\u30d7\u30fc\u30ea\u30f3\u30b0<\/li>\n\n\n\n<li>\u30a8\u30e9\u30fc\u30ec\u30fc\u30c8\u3068\u30ec\u30b9\u30dd\u30f3\u30b9\u30bf\u30a4\u30e0\u306e\u76e3\u8996<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u5b89\u5b9a\u6027\u306e\u5411\u4e0a<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30b7\u30b9\u30c6\u30e0\u72b6\u614b\u306b\u5fdc\u3058\u305f\u81ea\u52d5\u7684\u306a\u8ca0\u8377\u8abf\u6574<\/li>\n\n\n\n<li>\u30a8\u30e9\u30fc\u51e6\u7406\u3068\u30ea\u30c8\u30e9\u30a4\u306e\u6700\u9069\u5316<\/li>\n\n\n\n<li>\u8a73\u7d30\u306a\u30e1\u30c8\u30ea\u30af\u30b9\u53ce\u96c6\u306b\u3088\u308b\u30e2\u30cb\u30bf\u30ea\u30f3\u30b0<\/li>\n<\/ul>\n\n\n\n<p>\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u3053\u308c\u3089\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6700\u9069\u5316\u3092\u5b9f\u904b\u7528\u74b0\u5883\u3067\u7dad\u6301\u30fb\u76e3\u8996\u3059\u308b\u305f\u3081\u306e\u65b9\u6cd5\u3068\u3001\u4e00\u822c\u7684\u306a\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-29\">Guzzle\u306e\u904b\u7528\u3068\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0<\/h2>\n\n\n\n<p>Guzzle\u3092\u672c\u756a\u74b0\u5883\u3067\u5b89\u5b9a\u3057\u3066\u904b\u7528\u3059\u308b\u305f\u3081\u306b\u306f\u3001\u9069\u5207\u306a\u76e3\u8996\u4f53\u5236\u3068\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0\u4f53\u5236\u306e\u69cb\u7bc9\u304c\u4e0d\u53ef\u6b20\u3067\u3059\u3002\u3053\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u5b9f\u8df5\u7684\u306a\u904b\u7528\u65b9\u6cd5\u3068\u4e00\u822c\u7684\u306a\u554f\u984c\u306e\u89e3\u6c7a\u65b9\u6cd5\u3092\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-30\">\u5b9f\u904b\u7528\u3067\u306e\u76e3\u8996\u30dd\u30a4\u30f3\u30c8<\/h3>\n\n\n\n<p>\u5b9f\u904b\u7528\u74b0\u5883\u3067\u306eGuzzle\u306e\u72b6\u614b\u3092\u9069\u5207\u306b\u76e3\u8996\u3059\u308b\u305f\u3081\u306e\u5b9f\u88c5\u4f8b\u3092\u793a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\nnamespace App\\Monitoring;\n\nuse GuzzleHttp\\Client;\nuse GuzzleHttp\\HandlerStack;\nuse GuzzleHttp\\Middleware;\nuse Psr\\Log\\LoggerInterface;\nuse Prometheus\\CollectorRegistry;\n\nclass HttpClientMonitoring\n{\n    private $client;\n    private $logger;\n    private $metrics;\n\n    \/\/ \u30e1\u30c8\u30ea\u30af\u30b9\u7528\u306e\u5b9a\u6570\n    private const METRIC_PREFIX = 'http_client_';\n\n    public function __construct(\n        LoggerInterface $logger,\n        CollectorRegistry $registry\n    ) {\n        $this-&gt;logger = $logger;\n        $this-&gt;setupMetrics($registry);\n\n        $stack = HandlerStack::create();\n        $stack-&gt;push($this-&gt;createMonitoringMiddleware());\n\n        $this-&gt;client = new Client(['handler' =&gt; $stack]);\n    }\n\n    \/**\n     * \u30e1\u30c8\u30ea\u30af\u30b9\u306e\u521d\u671f\u8a2d\u5b9a\n     *\/\n    private function setupMetrics(CollectorRegistry $registry): void\n    {\n        $this-&gt;metrics = [\n            'requests_total' =&gt; $registry-&gt;getOrRegisterCounter(\n                self::METRIC_PREFIX, 'requests_total',\n                'Total number of HTTP requests',\n                ['method', 'host', 'status_code']\n            ),\n            'request_duration_seconds' =&gt; $registry-&gt;getOrRegisterHistogram(\n                self::METRIC_PREFIX, 'request_duration_seconds',\n                'HTTP request duration in seconds',\n                ['method', 'host'],\n                [0.1, 0.3, 0.5, 0.7, 1, 2, 3, 5, 7, 10]\n            ),\n            'response_size_bytes' =&gt; $registry-&gt;getOrRegisterHistogram(\n                self::METRIC_PREFIX, 'response_size_bytes',\n                'HTTP response size in bytes',\n                ['method', 'host']\n            )\n        ];\n    }\n\n    \/**\n     * \u30e2\u30cb\u30bf\u30ea\u30f3\u30b0\u7528\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u306e\u4f5c\u6210\n     *\/\n    private function createMonitoringMiddleware(): callable\n    {\n        return Middleware::tap(\n            \/\/ \u30ea\u30af\u30a8\u30b9\u30c8\u524d\u306e\u51e6\u7406\n            function ($request, $options) {\n                $options['start_time'] = microtime(true);\n            },\n            \/\/ \u30ec\u30b9\u30dd\u30f3\u30b9\u5f8c\u306e\u51e6\u7406\n            function ($request, $options, $response) {\n                $duration = microtime(true) - $options['start_time'];\n                $host = $request-&gt;getUri()-&gt;getHost();\n                $method = $request-&gt;getMethod();\n                $statusCode = $response-&gt;getStatusCode();\n\n                \/\/ \u30e1\u30c8\u30ea\u30af\u30b9\u306e\u8a18\u9332\n                $this-&gt;metrics['requests_total']-&gt;inc([\n                    'method' =&gt; $method,\n                    'host' =&gt; $host,\n                    'status_code' =&gt; $statusCode\n                ]);\n\n                $this-&gt;metrics['request_duration_seconds']-&gt;observe(\n                    $duration,\n                    ['method' =&gt; $method, 'host' =&gt; $host]\n                );\n\n                $this-&gt;metrics['response_size_bytes']-&gt;observe(\n                    $response-&gt;getBody()-&gt;getSize(),\n                    ['method' =&gt; $method, 'host' =&gt; $host]\n                );\n\n                \/\/ \u9045\u3044\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u30ed\u30b0\u8a18\u9332\n                if ($duration &gt; 1.0) {\n                    $this-&gt;logger-&gt;warning('Slow HTTP request detected', [\n                        'url' =&gt; (string)$request-&gt;getUri(),\n                        'method' =&gt; $method,\n                        'duration' =&gt; $duration,\n                        'status_code' =&gt; $statusCode\n                    ]);\n                }\n            }\n        );\n    }\n\n    \/**\n     * \u30d8\u30eb\u30b9\u30c1\u30a7\u30c3\u30af\u306e\u5b9f\u88c5\n     *\/\n    public function checkHealth(array $endpoints): array\n    {\n        $results = [];\n\n        foreach ($endpoints as $name =&gt; $url) {\n            try {\n                $startTime = microtime(true);\n                $response = $this-&gt;client-&gt;get($url, [\n                    'timeout' =&gt; 5,\n                    'connect_timeout' =&gt; 3\n                ]);\n                $duration = microtime(true) - $startTime;\n\n                $results[$name] = [\n                    'status' =&gt; 'healthy',\n                    'response_time' =&gt; $duration,\n                    'status_code' =&gt; $response-&gt;getStatusCode()\n                ];\n            } catch (\\Exception $e) {\n                $results[$name] = [\n                    'status' =&gt; 'unhealthy',\n                    'error' =&gt; $e-&gt;getMessage()\n                ];\n            }\n        }\n\n        return $results;\n    }\n\n    \/**\n     * \u76e3\u8996\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u7528\u306e\u30e1\u30c8\u30ea\u30af\u30b9\u53d6\u5f97\n     *\/\n    public function getMetrics(): array\n    {\n        return [\n            'total_requests' =&gt; $this-&gt;metrics['requests_total']-&gt;get(),\n            'average_duration' =&gt; $this-&gt;calculateAverageDuration(),\n            'error_rate' =&gt; $this-&gt;calculateErrorRate(),\n            'response_sizes' =&gt; $this-&gt;metrics['response_size_bytes']-&gt;get()\n        ];\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-31\">\u3088\u304f\u3042\u308b\u30a8\u30e9\u30fc\u3068\u305d\u306e\u89e3\u6c7a\u65b9\u6cd5<\/h3>\n\n\n\n<p>\u5b9f\u904b\u7528\u3067\u3088\u304f\u906d\u9047\u3059\u308b\u30a8\u30e9\u30fc\u3068\u305d\u306e\u5bfe\u51e6\u65b9\u6cd5\u3092\u3001\u5177\u4f53\u7684\u306a\u5b9f\u88c5\u4f8b\u3068\u3068\u3082\u306b\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\nnamespace App\\Troubleshooting;\n\nuse GuzzleHttp\\Client;\nuse GuzzleHttp\\Exception\\ConnectException;\nuse GuzzleHttp\\Exception\\RequestException;\nuse GuzzleHttp\\Exception\\ServerException;\n\nclass HttpTroubleshooter\n{\n    private const MAX_RETRIES = 3;\n    private const INITIAL_DELAY = 1000; \/\/ \u30df\u30ea\u79d2\n\n    \/**\n     * \u4e00\u822c\u7684\u306a\u30a8\u30e9\u30fc\u306e\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\n     *\/\n    public static function handleCommonErrors(\\Throwable $e): array\n    {\n        $diagnostics = [\n            'error_type' =&gt; get_class($e),\n            'message' =&gt; $e-&gt;getMessage(),\n            'recommendations' =&gt; []\n        ];\n\n        if ($e instanceof ConnectException) {\n            $diagnostics['recommendations'] = [\n                '\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u63a5\u7d9a\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044',\n                'DNS\u306e\u8a2d\u5b9a\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044',\n                '\u30d5\u30a1\u30a4\u30a2\u30a6\u30a9\u30fc\u30eb\u306e\u8a2d\u5b9a\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044',\n                '\u30d7\u30ed\u30ad\u30b7\u8a2d\u5b9a\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044'\n            ];\n        } elseif ($e instanceof ServerException) {\n            $diagnostics['recommendations'] = [\n                '\u30b5\u30fc\u30d0\u30fc\u306e\u72b6\u614b\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044',\n                '\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u59a5\u5f53\u6027\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044',\n                '\u30ec\u30fc\u30c8\u5236\u9650\u306b\u5f15\u3063\u304b\u304b\u3063\u3066\u3044\u306a\u3044\u304b\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044'\n            ];\n        } elseif ($e instanceof RequestException) {\n            $diagnostics['recommendations'] = [\n                '\u30ea\u30af\u30a8\u30b9\u30c8\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044',\n                '\u8a8d\u8a3c\u60c5\u5831\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044',\n                'API\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044'\n            ];\n        }\n\n        return $diagnostics;\n    }\n\n    \/**\n     * SSL\/TLS\u95a2\u9023\u306e\u554f\u984c\u8a3a\u65ad\n     *\/\n    public static function diagnoseSslIssues(string $url): array\n    {\n        $diagnostics = [];\n\n        \/\/ SSL\u8a3c\u660e\u66f8\u306e\u691c\u8a3c\n        $certInfo = [];\n        $ch = curl_init($url);\n        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);\n        curl_setopt($ch, CURLOPT_VERBOSE, true);\n        curl_setopt($ch, CURLOPT_CERTINFO, true);\n        curl_exec($ch);\n        $certInfo = curl_getinfo($ch, CURLINFO_CERTINFO);\n        curl_close($ch);\n\n        if (empty($certInfo)) {\n            $diagnostics[] = 'SSL\u8a3c\u660e\u66f8\u306e\u60c5\u5831\u304c\u53d6\u5f97\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f';\n        } else {\n            $diagnostics[] = '\u8a3c\u660e\u66f8\u306e\u6709\u52b9\u671f\u9650: ' . $certInfo[0]['Expire Date'];\n            if (strtotime($certInfo[0]['Expire Date']) &lt; time()) {\n                $diagnostics[] = '\u8b66\u544a: SSL\u8a3c\u660e\u66f8\u304c\u671f\u9650\u5207\u308c\u3067\u3059';\n            }\n        }\n\n        return $diagnostics;\n    }\n\n    \/**\n     * \u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u554f\u984c\u306e\u8a3a\u65ad\u3068\u89e3\u6c7a\n     *\/\n    public static function handleTimeoutIssues(\n        Client $client,\n        string $url,\n        array $options = []\n    ): void {\n        $defaultOptions = [\n            'connect_timeout' =&gt; 5,\n            'timeout' =&gt; 30,\n            'read_timeout' =&gt; 30\n        ];\n\n        $options = array_merge($defaultOptions, $options);\n\n        try {\n            $response = $client-&gt;get($url, $options);\n        } catch (\\Exception $e) {\n            if ($e instanceof ConnectException) {\n                throw new \\RuntimeException(\n                    '\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u3002\u4ee5\u4e0b\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\uff1a' . PHP_EOL .\n                    '- \u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u63a5\u7d9a\u306e\u72b6\u614b' . PHP_EOL .\n                    '- \u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u8a2d\u5b9a\u5024\u306e\u59a5\u5f53\u6027' . PHP_EOL .\n                    '- \u30b5\u30fc\u30d0\u30fc\u306e\u5fdc\u7b54\u6642\u9593',\n                    0,\n                    $e\n                );\n            }\n            throw $e;\n        }\n    }\n\n    \/**\n     * \u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u306e\u554f\u984c\u8a3a\u65ad\n     *\/\n    public static function diagnoseMemoryIssues(): array\n    {\n        return [\n            'current_usage' =&gt; memory_get_usage(true),\n            'peak_usage' =&gt; memory_get_peak_usage(true),\n            'memory_limit' =&gt; ini_get('memory_limit'),\n            'recommendations' =&gt; [\n                '\u30b9\u30c8\u30ea\u30fc\u30df\u30f3\u30b0\u51e6\u7406\u306e\u4f7f\u7528\u3092\u691c\u8a0e\u3057\u3066\u304f\u3060\u3055\u3044',\n                '\u30d0\u30c3\u30c1\u30b5\u30a4\u30ba\u3092\u8abf\u6574\u3057\u3066\u304f\u3060\u3055\u3044',\n                '\u30e1\u30e2\u30ea\u30ea\u30df\u30c3\u30c8\u3092\u9069\u5207\u306b\u8a2d\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044'\n            ]\n        ];\n    }\n}<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-32\">\u4e00\u822c\u7684\u306a\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0\u306e\u30c1\u30a7\u30c3\u30af\u30ea\u30b9\u30c8<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u63a5\u7d9a\u30a8\u30e9\u30fc<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u63a5\u7d9a\u306e\u78ba\u8a8d<\/li>\n\n\n\n<li>DNS\u8a2d\u5b9a\u306e\u78ba\u8a8d<\/li>\n\n\n\n<li>\u30d7\u30ed\u30ad\u30b7\u8a2d\u5b9a\u306e\u78ba\u8a8d<\/li>\n\n\n\n<li>\u30d5\u30a1\u30a4\u30a2\u30a6\u30a9\u30fc\u30eb\u8a2d\u5b9a\u306e\u78ba\u8a8d<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u30a8\u30e9\u30fc<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u8a2d\u5b9a\u5024\u306e\u8abf\u6574<\/li>\n\n\n\n<li>\u63a5\u7d9a\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u3068\u8aad\u307f\u53d6\u308a\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u306e\u533a\u5225<\/li>\n\n\n\n<li>\u5927\u304d\u306a\u30ec\u30b9\u30dd\u30f3\u30b9\u306b\u5bfe\u3059\u308b\u30b9\u30c8\u30ea\u30fc\u30df\u30f3\u30b0\u51e6\u7406\u306e\u691c\u8a0e<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>SSL\/TLS\u95a2\u9023\u306e\u554f\u984c<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u8a3c\u660e\u66f8\u306e\u6709\u52b9\u671f\u9650\u78ba\u8a8d<\/li>\n\n\n\n<li>\u8a3c\u660e\u66f8\u30c1\u30a7\u30fc\u30f3\u306e\u691c\u8a3c<\/li>\n\n\n\n<li>SSL\/TLS\u8a2d\u5b9a\u306e\u78ba\u8a8d<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30e1\u30e2\u30ea\u95a2\u9023\u306e\u554f\u984c<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u306e\u76e3\u8996<\/li>\n\n\n\n<li>\u30b9\u30c8\u30ea\u30fc\u30df\u30f3\u30b0\u51e6\u7406\u306e\u6d3b\u7528<\/li>\n\n\n\n<li>\u30ac\u30d9\u30fc\u30b8\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306e\u6700\u9069\u5316<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u554f\u984c<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u540c\u6642\u63a5\u7d9a\u6570\u306e\u8abf\u6574<\/li>\n\n\n\n<li>\u30ad\u30fc\u30d7\u30a2\u30e9\u30a4\u30d6\u8a2d\u5b9a\u306e\u6700\u9069\u5316<\/li>\n\n\n\n<li>DNS\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u6d3b\u7528<\/li>\n<\/ul>\n\n\n\n<p>\u5b9f\u904b\u7528\u74b0\u5883\u3067\u306eGuzzle\u306e\u5b89\u5b9a\u904b\u7528\u306b\u306f\u3001\u4e0a\u8a18\u306e\u3088\u3046\u306a\u5305\u62ec\u7684\u306a\u76e3\u8996\u4f53\u5236\u3068\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0\u4f53\u5236\u306e\u69cb\u7bc9\u304c\u91cd\u8981\u3067\u3059\u3002\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u3053\u308c\u307e\u3067\u306e\u5185\u5bb9\u3092\u7dcf\u62ec\u3057\u3001Guzzle\u306e\u5c06\u6765\u7684\u306a\u5c55\u671b\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-33\">\u307e\u3068\u3081\uff1a\u6b21\u4e16\u4ee3\u306eHTTP\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u30e9\u30a4\u30d6\u30e9\u30ea\u3068\u3057\u3066\u306eGuzzle<\/h2>\n\n\n\n<p>\u672c\u8a18\u4e8b\u3067\u306f\u3001Guzzle\u3092PHP\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u52b9\u679c\u7684\u306b\u6d3b\u7528\u3059\u308b\u305f\u3081\u306e\u69d8\u3005\u306a\u30c6\u30af\u30cb\u30c3\u30af\u3068\u5b9f\u8df5\u7684\u306a\u5b9f\u88c5\u4f8b\u3092\u7d39\u4ecb\u3057\u3066\u304d\u307e\u3057\u305f\u3002\u3053\u3053\u3067\u306f\u3001Guzzle\u306e\u5c0e\u5165\u304c\u3082\u305f\u3089\u3059\u5177\u4f53\u7684\u306a\u52b9\u679c\u3068\u3001\u4eca\u5f8c\u306e\u5c55\u671b\u306b\u3064\u3044\u3066\u307e\u3068\u3081\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-34\">Guzzle\u5c0e\u5165\u304c\u3082\u305f\u3089\u3059\u958b\u767a\u52b9\u7387\u306e\u5411\u4e0a<\/h3>\n\n\n\n<p>Guzzle\u306e\u5c0e\u5165\u306b\u3088\u308a\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u5177\u4f53\u7684\u306a\u52b9\u679c\u304c\u671f\u5f85\u3067\u304d\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30b3\u30fc\u30c9\u306e\u54c1\u8cea\u5411\u4e0a<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\n\/\/ \u5f93\u6765\u306e\u5b9f\u88c5\n$ch = curl_init();\ncurl_setopt($ch, CURLOPT_URL, \"https:\/\/api.example.com\/data\");\ncurl_setopt($ch, CURLOPT_RETURNTRANSFER, true);\ncurl_setopt($ch, CURLOPT_HTTPHEADER, [\n    \"Authorization: Bearer \" . $token,\n    \"Accept: application\/json\"\n]);\n$response = curl_exec($ch);\n$error = curl_error($ch);\ncurl_close($ch);\n\nif ($error) {\n    throw new \\Exception(\"cURL Error: \" . $error);\n}\n\n$data = json_decode($response, true);\n\n\/\/ Guzzle\u3092\u4f7f\u7528\u3057\u305f\u5b9f\u88c5\n$client = new GuzzleHttp\\Client();\ntry {\n    $response = $client-&gt;get(\"https:\/\/api.example.com\/data\", [\n        'headers' =&gt; [\n            'Authorization' =&gt; 'Bearer ' . $token,\n            'Accept' =&gt; 'application\/json'\n        ]\n    ]);\n    $data = json_decode($response-&gt;getBody(), true);\n} catch (GuzzleHttp\\Exception\\GuzzleException $e) {\n    \/\/ \u69cb\u9020\u5316\u3055\u308c\u305f\u4f8b\u5916\u51e6\u7406\n    handleGuzzleException($e);\n}<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u4fdd\u5b88\u6027\u306e\u5411\u4e0a<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30e2\u30c0\u30f3\u306a\u8a2d\u8a08\u30d1\u30bf\u30fc\u30f3\u306e\u63a1\u7528<\/li>\n\n\n\n<li>\u4e00\u8cab\u3057\u305f\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u306e\u63d0\u4f9b<\/li>\n\n\n\n<li>\u6a19\u6e96\u5316\u3055\u308c\u305f\u4f8b\u5916\u51e6\u7406<\/li>\n\n\n\n<li>\u30c6\u30b9\u30bf\u30d3\u30ea\u30c6\u30a3\u306e\u5411\u4e0a<\/li>\n<\/ul>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u6700\u9069\u5316<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u52b9\u7387\u7684\u306a\u975e\u540c\u671f\u51e6\u7406<\/li>\n\n\n\n<li>\u30b3\u30cd\u30af\u30b7\u30e7\u30f3\u30d7\u30fc\u30ea\u30f3\u30b0<\/li>\n\n\n\n<li>\u9069\u5fdc\u7684\u306a\u30ea\u30c8\u30e9\u30a4\u6226\u7565<\/li>\n\n\n\n<li>\u30ad\u30e3\u30c3\u30b7\u30e5\u7ba1\u7406<\/li>\n<\/ul>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u904b\u7528\u52b9\u7387\u306e\u5411\u4e0a<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5305\u62ec\u7684\u306a\u30e2\u30cb\u30bf\u30ea\u30f3\u30b0<\/li>\n\n\n\n<li>\u52b9\u679c\u7684\u306a\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0<\/li>\n\n\n\n<li>\u67d4\u8edf\u306a\u30b9\u30b1\u30fc\u30ea\u30f3\u30b0<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-35\">\u4eca\u5f8c\u306e\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u3068\u6ce8\u76ee\u3059\u3079\u304d\u65b0\u6a5f\u80fd<\/h3>\n\n\n\n<p>Guzzle\u306e\u4eca\u5f8c\u306e\u5c55\u958b\u306b\u3064\u3044\u3066\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u767a\u5c55\u304c\u671f\u5f85\u3055\u308c\u3066\u3044\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>HTTP\/3\u30b5\u30dd\u30fc\u30c8\u306e\u5f37\u5316<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\n\/\/ \u5c06\u6765\u7684\u306aHTTP\/3\u30b5\u30dd\u30fc\u30c8\u306e\u5b9f\u88c5\u4f8b\n$client = new GuzzleHttp\\Client([\n    'version' =&gt; 3.0,  \/\/ HTTP\/3\u306e\u6307\u5b9a\n    'quic' =&gt; [        \/\/ QUIC\u8a2d\u5b9a\n        'idle_timeout' =&gt; 30,\n        'max_streams' =&gt; 100\n    ]\n]);\n\n\/\/ WebTransport\u306e\u30b5\u30dd\u30fc\u30c8\n$client = new GuzzleHttp\\Client([\n    'transport' =&gt; 'webtransport',\n    'options' =&gt; [\n        'fallback' =&gt; 'http2'  \/\/ \u30d5\u30a9\u30fc\u30eb\u30d0\u30c3\u30af\u30aa\u30d7\u30b7\u30e7\u30f3\n    ]\n]);<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>WebSockets\u306e\u7d71\u5408\u5f37\u5316<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\n\/\/ WebSockets\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306e\u6539\u5584\u4f8b\n$wsClient = new GuzzleHttp\\WebSocket\\Client(\n    'wss:\/\/example.com\/socket',\n    [\n        'protocols' =&gt; ['graphql-ws'],\n        'headers' =&gt; ['Sec-WebSocket-Protocol' =&gt; 'graphql-ws'],\n        'ping_interval' =&gt; 30,\n        'reconnect' =&gt; true\n    ]\n);\n\n\/\/ \u30a4\u30d9\u30f3\u30c8\u30d9\u30fc\u30b9\u306e\u51e6\u7406\n$wsClient-&gt;on('message', function ($message) {\n    processWebSocketMessage($message);\n});\n\n$wsClient-&gt;on('close', function ($code, $reason) {\n    handleWebSocketClose($code, $reason);\n});<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>GraphQL\u7d71\u5408\u306e\u5f37\u5316<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\n\/\/ GraphQL\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306e\u6a5f\u80fd\u5f37\u5316\u4f8b\n$graphqlClient = new GuzzleHttp\\GraphQL\\Client([\n    'base_uri' =&gt; 'https:\/\/api.example.com\/graphql',\n    'schema' =&gt; 'path\/to\/schema.graphql',\n    'cache' =&gt; [\n        'query_cache' =&gt; true,\n        'schema_cache' =&gt; true\n    ]\n]);\n\n\/\/ \u578b\u5b89\u5168\u306a\u30af\u30a8\u30ea\u5b9f\u884c\n$result = $graphqlClient-&gt;query(\n    'GetUserData',\n    ['id' =&gt; $userId],\n    ['User' =&gt; ['id', 'name', 'email']]\n);<\/pre>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li><strong>\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u6a5f\u80fd\u306e\u5f37\u5316<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\n\/\/ \u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u5f37\u5316\u6a5f\u80fd\u306e\u4f8b\n$client = new GuzzleHttp\\Client([\n    'security' =&gt; [\n        'tls' =&gt; [\n            'verify_peer' =&gt; true,\n            'verify_host' =&gt; true,\n            'min_version' =&gt; 'TLSv1.3',\n            'ciphers' =&gt; 'TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256'\n        ],\n        'http_security_headers' =&gt; true,\n        'content_security_policy' =&gt; true\n    ]\n]);<\/pre>\n\n\n\n<ol start=\"5\" class=\"wp-block-list\">\n<li><strong>\u958b\u767a\u8005\u4f53\u9a13\u306e\u5411\u4e0a<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\n\/\/ \u30c7\u30d0\u30c3\u30b0\u6a5f\u80fd\u306e\u5f37\u5316\u4f8b\n$client = new GuzzleHttp\\Client([\n    'debug' =&gt; [\n        'request_logger' =&gt; true,\n        'response_logger' =&gt; true,\n        'performance_metrics' =&gt; true,\n        'dev_tools_integration' =&gt; true\n    ]\n]);\n\n\/\/ IDE\u7d71\u5408\u306e\u6539\u5584\n$client-&gt;request('GET', 'api\/users')\n    -&gt;withMiddleware(new DebugMiddleware())\n    -&gt;withRetry(3)\n    -&gt;withCache(60)\n    -&gt;execute();<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u6a5f\u80fd\u5f37\u5316\u306b\u3088\u308a\u3001Guzzle\u306f\u3088\u308a\u4e00\u5c64\u3001\u30e2\u30c0\u30f3\u306aPHP\u958b\u767a\u306b\u304a\u3051\u308b\u91cd\u8981\u306a\u30c4\u30fc\u30eb\u3068\u3057\u3066\u306e\u5730\u4f4d\u3092\u78ba\u7acb\u3057\u3066\u3044\u304f\u3053\u3068\u304c\u671f\u5f85\u3055\u308c\u307e\u3059\u3002\u7279\u306b\u4ee5\u4e0b\u306e\u5206\u91ce\u3067\u306e\u767a\u5c55\u304c\u6ce8\u76ee\u3055\u308c\u3066\u3044\u307e\u3059\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u30af\u30e9\u30a6\u30c9\u30cd\u30a4\u30c6\u30a3\u30d6\u5bfe\u5fdc<\/strong>: \u30b3\u30f3\u30c6\u30ca\u5316\u74b0\u5883\u3067\u306e\u6700\u9069\u5316<\/li>\n\n\n\n<li><strong>\u30de\u30a4\u30af\u30ed\u30b5\u30fc\u30d3\u30b9\u9023\u643a<\/strong>: \u30b5\u30fc\u30d3\u30b9\u30e1\u30c3\u30b7\u30e5\u3068\u306e\u7d71\u5408<\/li>\n\n\n\n<li><strong>\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u901a\u4fe1<\/strong>: WebSockets\u3068Server-Sent Events\u306e\u5f37\u5316<\/li>\n\n\n\n<li><strong>\u958b\u767a\u8005\u4f53\u9a13<\/strong>: \u30c7\u30d0\u30c3\u30b0\u30c4\u30fc\u30eb\u3068IDE\u7d71\u5408\u306e\u6539\u5584<\/li>\n\n\n\n<li><strong>\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3<\/strong>: \u6700\u65b0\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u6a19\u6e96\u3078\u306e\u5bfe\u5fdc<\/li>\n<\/ul>\n\n\n\n<p>Guzzle\u306f\u3001PHP\u30a8\u30b3\u30b7\u30b9\u30c6\u30e0\u306b\u304a\u3051\u308b\u91cd\u8981\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u3068\u3057\u3066\u3001\u4eca\u5f8c\u3082\u9032\u5316\u3092\u7d9a\u3051\u3066\u3044\u304f\u3067\u3057\u3087\u3046\u3002\u672c\u8a18\u4e8b\u3067\u7d39\u4ecb\u3057\u305f\u5b9f\u88c5\u30c6\u30af\u30cb\u30c3\u30af\u3068\u4f75\u305b\u3066\u3001\u3053\u308c\u3089\u306e\u65b0\u6a5f\u80fd\u3092\u6d3b\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u3088\u308a\u52b9\u7387\u7684\u3067\u5805\u7262\u306a\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u958b\u767a\u304c\u53ef\u80fd\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Warning: Undefined array key &#8220;is_admin&#8221; in \/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/ &#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":{"0":"post-2466","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-php","7":"nothumb"},"_links":{"self":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/2466","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2466"}],"version-history":[{"count":2,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/2466\/revisions"}],"predecessor-version":[{"id":2468,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/2466\/revisions\/2468"}],"wp:attachment":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2466"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2466"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2466"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}