{"id":908,"date":"2025-06-10T00:46:36","date_gmt":"2025-06-09T16:46:36","guid":{"rendered":"https:\/\/www.zhaozhao123.cn\/wpcms\/wpdt\/908.html"},"modified":"2025-06-10T00:46:36","modified_gmt":"2025-06-09T16:46:36","slug":"%e4%bb%80%e4%b9%88%e6%98%afweb%e6%8e%a8%e9%80%81%e9%80%9a%e7%9f%a5%e4%bb%a5%e5%8f%8a%e5%ae%83%e4%bb%ac%e5%a6%82%e4%bd%95%e5%b7%a5%e4%bd%9c%ef%bc%9f%ef%bc%88%e8%a7%a3%e9%87%8a%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.zhaozhao123.cn\/wpcms\/post\/908.html","title":{"rendered":"\u4ec0\u4e48\u662fWeb\u63a8\u9001\u901a\u77e5\u4ee5\u53ca\u5b83\u4eec\u5982\u4f55\u5de5\u4f5c\uff1f\uff08\u89e3\u91ca\uff09"},"content":{"rendered":"<div class=\"wp-block-columns p-0 border is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-columns px-4 py-3 border-bottom has-background is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\" style=\"background:linear-gradient(243deg,rgb(238,238,238) 0%,rgba(58,166,242,0.15) 100%)\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-group is-nowrap is-layout-flex wp-container-core-group-is-layout-6c531013 wp-block-group-is-layout-flex\">\r\n<h2 class=\"wp-block-heading my-0\">&#20889; Bug&#24037;&#31243;&#24072;&#65306;<\/h2>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n\r\n\r\n\r\n<div class=\"wp-block-columns px-xl-5 px-4 py-xl-4 py-3 is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<h3>Web&#25512;&#36865;&#36890;&#30693;&#31616;&#20171;<\/h3>\n<p>Web&#25512;&#36865;&#36890;&#30693;&#26159;&#19968;&#31181;&#25216;&#26415;&#65292;&#20801;&#35768;&#26381;&#21153;&#22120;&#21521;&#23458;&#25143;&#31471;&#35774;&#22791;&#65288;&#22914;&#25163;&#26426;&#12289;&#24179;&#26495;&#30005;&#33041;&#25110;&#32593;&#39029;&#27983;&#35272;&#22120;&#65289;&#20027;&#21160;&#21457;&#36865;&#20449;&#24687;&#65292;&#32780;&#19981;&#38656;&#35201;&#29992;&#25143;&#30340;&#20027;&#21160;&#25805;&#20316;&#12290;&#36825;&#31181;&#36890;&#30693;&#21487;&#20197;&#29992;&#20110;&#21508;&#31181;&#22330;&#26223;&#65292;&#20363;&#22914;&#24212;&#29992;&#26356;&#26032;&#25552;&#37266;&#12289;&#37325;&#35201;&#28040;&#24687;&#36890;&#30693;&#31561;&#12290;<\/p>\n<h3>&#22914;&#20309;&#24037;&#20316;&#65311;<\/h3>\n<ol>\n<li>\n<p><strong>&#26381;&#21153;&#22120;&#31471;&#37197;&#32622;<\/strong>&#65306;&#39318;&#20808;&#65292;&#20320;&#38656;&#35201;&#22312;&#26381;&#21153;&#22120;&#19978;&#35774;&#32622;&#19968;&#20010;&#26381;&#21153;&#22120;&#31471;&#30340;Web&#26381;&#21153;&#65292;&#27604;&#22914;Node.js&#12289;Python Flask&#25110;PHP&#31561;&#12290;&#36825;&#20123;&#26381;&#21153;&#20250;&#23450;&#26399;&#26816;&#26597;&#26159;&#21542;&#26377;&#26032;&#30340;&#36890;&#30693;&#38656;&#35201;&#21457;&#36865;&#12290;<\/p>\n<\/li>\n<li>\n<p><strong>&#23458;&#25143;&#31471;&#35746;&#38405;<\/strong>&#65306;&#29992;&#25143;&#36890;&#36807;&#27983;&#35272;&#22120;&#25110;&#20854;&#20182;&#25903;&#25345;Web Push&#30340;&#24037;&#20855;&#65288;&#22914;Chrome&#25193;&#23637;&#25110;iOS App&#65289;&#35746;&#38405;&#29305;&#23450;&#30340;&#36890;&#30693;&#31867;&#22411;&#12290;&#24403;&#26377;&#26032;&#36890;&#30693;&#26102;&#65292;&#36825;&#20123;&#24037;&#20855;&#20250;&#33258;&#21160;&#25509;&#25910;&#24182;&#26174;&#31034;&#36890;&#30693;&#12290;<\/p>\n<\/li>\n<li>\n<p><strong>&#25512;&#36865;&#21327;&#35758;<\/strong>&#65306;&#29616;&#20195;&#30340;Web&#25512;&#36865;&#36890;&#24120;&#20351;&#29992;WebSockets&#65288;WebSocket&#65289;&#12289;SignalR&#25110;HTML5&#30340;Push API&#26469;&#20256;&#36755;&#25968;&#25454;&#12290;&#36825;&#20123;&#21327;&#35758;&#30830;&#20445;&#20102;&#25968;&#25454;&#30340;&#23433;&#20840;&#24615;&#21644;&#23454;&#26102;&#24615;&#12290;<\/p>\n<\/li>\n<li>\n<p><strong>&#23433;&#20840;&#21644;&#38544;&#31169;<\/strong>&#65306;&#20026;&#20102;&#20445;&#25252;&#29992;&#25143;&#30340;&#38544;&#31169;&#21644;&#23433;&#20840;&#24615;&#65292;&#25512;&#36865;&#36890;&#30693;&#36890;&#24120;&#37319;&#29992;&#21152;&#23494;&#25216;&#26415;&#21644;&#23433;&#20840;&#21327;&#35758;&#65292;&#22914;HTTPS&#65292;&#20197;&#38450;&#27490;&#25968;&#25454;&#34987;&#31363;&#21462;&#12290;<\/p>\n<\/li>\n<\/ol>\n<h3>&#31034;&#20363;&#20195;&#30721;<\/h3>\n<h4>Node.js &#23454;&#29616;<\/h4>\n<pre><code class=\"language-javascript\">const express = require('express');\nconst app = express();\nconst http = require('http').Server(app);\nconst io = require('socket.io')(http);\n\napp.use(express.static(__dirname + '\/public'));\n\nio.on('connection', (socket) =&gt; {\n    console.log('New client connected');\n\n    \/\/ &#20363;&#23376;&#65306;&#25512;&#36865;&#19968;&#26465;&#31616;&#21333;&#30340;&#28040;&#24687;\n    socket.emit('message', 'Hello, this is a message from the server!');\n});\n\nhttp.listen(3000, () =&gt; {\n    console.log('Listening on *:3000');\n});<\/code><\/pre>\n<h4>&#20351;&#29992;&#27493;&#39588;&#65306;<\/h4>\n<ol>\n<li>&#21019;&#24314;&#19968;&#20010;&#26032;&#30340;Node.js&#39033;&#30446;&#12290;<\/li>\n<li>&#23433;&#35013;&#24517;&#35201;&#30340;&#20381;&#36182;&#65306;\n<pre><code class=\"language-bash\">npm install express socket.io<\/code><\/pre><\/li>\n<li>&#32534;&#20889;&#19978;&#36848;&#20195;&#30721;&#21040;<code>server.js<\/code>&#25991;&#20214;&#20013;&#12290;<\/li>\n<li>&#36816;&#34892;&#26381;&#21153;&#22120;&#65306;\n<pre><code class=\"language-bash\">node server.js<\/code><\/pre><\/li>\n<li>&#25171;&#24320;&#27983;&#35272;&#22120;&#65292;&#35775;&#38382;<code><a href=\"https:\/\/www.zhaozhao123.cn\/skin\/go?url=aHR0cDovL2xvY2FsaG9zdA==\" rel=\"noopener noreferrer nofollow\">http:\/\/localhost<\/a>3000<\/code>&#12290;&#20320;&#24212;&#35813;&#33021;&#30475;&#21040;&ldquo;Hello, this is a message from the server!&rdquo;&#30340;&#28040;&#24687;&#12290;<\/li>\n<\/ol>\n<p>&#36825;&#20010;&#31034;&#20363;&#23637;&#31034;&#20102;&#22522;&#26412;&#30340;Web Push&#21151;&#33021;&#65292;&#21253;&#25324;&#26381;&#21153;&#22120;&#31471;&#30340;&#22788;&#29702;&#36923;&#36753;&#21644;&#23458;&#25143;&#31471;&#30340;&#36830;&#25509;&#19982;&#20107;&#20214;&#30417;&#21548;&#12290;&#23454;&#38469;&#37096;&#32626;&#26102;&#65292;&#20320;&#38656;&#35201;&#32771;&#34385;&#26356;&#22810;&#30340;&#23433;&#20840;&#25514;&#26045;&#21644;&#25216;&#26415;&#32454;&#33410;&#12290;<\/p>\n<h3>&#24635;&#32467;<\/h3>\n<p>Web&#25512;&#36865;&#36890;&#30693;&#21033;&#29992;&#20102;&#29616;&#20195;&#20114;&#32852;&#32593;&#25216;&#26415;&#30340;&#20248;&#21183;&#65292;&#20026;&#29992;&#25143;&#25552;&#20379;&#20102;&#19968;&#31181;&#39640;&#25928;&#30340;&#20449;&#24687;&#20256;&#36798;&#26041;&#24335;&#12290;&#26080;&#35770;&#26159;&#20225;&#19994;&#20869;&#37096;&#36890;&#35759;&#36824;&#26159;&#36328;&#24179;&#21488;&#30340;&#24212;&#29992;&#36890;&#30693;&#65292;&#37117;&#33021;&#20511;&#21161;&#36825;&#19968;&#25216;&#26415;&#23454;&#29616;&#26356;&#22909;&#30340;&#29992;&#25143;&#20307;&#39564;&#21644;&#26381;&#21153;&#25928;&#29575;&#12290;<\/p>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div><div class=\"wp-block-columns p-0 border is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-columns px-4 py-3 border-bottom has-background is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\" style=\"background:linear-gradient(243deg,rgb(238,238,238) 0%,rgba(58,166,242,0.15) 100%)\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-group is-nowrap is-layout-flex wp-container-core-group-is-layout-6c531013 wp-block-group-is-layout-flex\">\r\n<h2 class=\"wp-block-heading my-0\">&#40657;&#26495;IDE&#25945;&#20070;&#21280;&#65306;<\/h2>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n\r\n\r\n\r\n<div class=\"wp-block-columns px-xl-5 px-4 py-xl-4 py-3 is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<h3>Web Push Notification&#31616;&#20171;<\/h3>\n<p>Web Push Notifications&#26159;&#19968;&#31181;&#22522;&#20110;HTTP&#21327;&#35758;&#30340;&#28040;&#24687;&#25512;&#36865;&#25216;&#26415;&#65292;&#20801;&#35768;&#24212;&#29992;&#31243;&#24207;&#21521;&#29992;&#25143;&#21457;&#36865;&#23454;&#26102;&#28040;&#24687;&#12290;&#36825;&#31181;&#31867;&#22411;&#30340;&#25512;&#36865;&#21487;&#20197;&#22312;&#29992;&#25143;&#30340;&#27983;&#35272;&#22120;&#19978;&#26174;&#31034;&#65292;&#19981;&#38656;&#35201;&#25171;&#24320;&#26032;&#30340;&#31383;&#21475;&#25110;&#26631;&#31614;&#39029;&#12290;<\/p>\n<p><strong>Web Push Notifications&#30340;&#24037;&#20316;&#21407;&#29702;<\/strong>&#65306;<\/p>\n<ol>\n<li><strong>&#35746;&#38405;<\/strong>&#65306;&#23458;&#25143;&#31471;&#65288;&#22914;&#25163;&#26426;&#24212;&#29992;&#65289;&#36890;&#36807;&#35774;&#32622;&#29305;&#23450;&#30340;URL&#26469;&#35746;&#38405;&#29305;&#23450;&#30340;&#36890;&#30693;&#26381;&#21153;&#12290;<\/li>\n<li><strong>&#21457;&#24067;<\/strong>&#65306;&#26381;&#21153;&#22120;&#23558;&#28040;&#24687;&#25512;&#36865;&#21040;&#35746;&#38405;&#32773;&#12290;<\/li>\n<li><strong>&#25509;&#25910;<\/strong>&#65306;&#35746;&#38405;&#32773;&#25509;&#25910;&#21040;&#28040;&#24687;&#21518;&#65292;&#21487;&#20197;&#20915;&#23450;&#26159;&#21542;&#25509;&#21463;&#21644;&#22788;&#29702;&#23427;&#12290;<\/li>\n<\/ol>\n<h3>&#23454;&#36341;&#25805;&#20316;<\/h3>\n<p>&#20551;&#35774;&#25105;&#20204;&#26377;&#19968;&#20010;&#21517;&#20026;&ldquo;ExampleApp&rdquo;&#30340;&#32593;&#31449;&#65292;&#38656;&#35201;&#21521;&#27880;&#20876;&#30340;&#29992;&#25143;&#21457;&#36865;&#19968;&#20123;&#36890;&#30693;&#12290;&#20197;&#19979;&#26159;&#19968;&#20123;&#22522;&#26412;&#30340;&#27493;&#39588;&#21644;&#31034;&#20363;&#20195;&#30721;&#65306;<\/p>\n<h4>1. &#21019;&#24314;WebPush&#26381;&#21153;<\/h4>\n<p>&#39318;&#20808;&#65292;&#20320;&#38656;&#35201;&#21019;&#24314;&#19968;&#20010;WebPush&#26381;&#21153;&#12290;&#36825;&#26159;&#19968;&#20010;&#31616;&#21333;&#30340;PHP&#33050;&#26412;&#65292;&#29992;&#20110;&#29983;&#25104;HTTP&#35831;&#27714;&#21040;&#26381;&#21153;&#22120;&#31471;&#30340;URL&#20197;&#33719;&#21462;WebPush&#26381;&#21153;&#30340;API&#23494;&#38053;&#12290;<\/p>\n<pre><code class=\"language-php\">&lt;?php\n\/\/ Replace with your own API key and secret\n$apiKey = 'your-api-key';\n$secretKey = 'your-secret-key';\n\nfunction createPushService() {\n    $url = \"<a href=\"https:\/\/www.zhaozhao123.cn\/skin\/go?url=aHR0cHM6Ly9hcGkucHVzaGVyLmNvbS92Mi9zZXJ2aWNlcw==\" rel=\"noopener noreferrer nofollow\">https:\/\/api.pusher.com\/v2\/services<\/a>\";\n    $data = [\n        'name' =&gt; 'ExampleApp',\n        'description' =&gt; 'This is an example of a web push service.',\n        'key' =&gt; $apiKey,\n        'secret' =&gt; $secretKey,\n        'priority' =&gt; 500,\n        'auto_renewal' =&gt; true,\n        'renewal_interval' =&gt; 604800, \/\/ 7 days in seconds\n        'enabled' =&gt; true,\n    ];\n\n    $headers = [\n        'Content-Type: application\/json',\n        'Authorization: Basic ' . base64_encode($apiKey . ':' . $secretKey),\n    ];\n\n    $response = file_get_contents($url, false, stream_context_create([\n        'http' =&gt; ['method' =&gt; 'POST', 'header' =&gt; implode(\"rn\", $headers)],\n    ]));\n\n    if ($response) {\n        return json_decode($response);\n    } else {\n        throw new Exception('Failed to retrieve push service details');\n    }\n}\n\n$pushService = createPushService();<\/code><\/pre>\n<h4>2. &#20351;&#29992;WebPush&#21457;&#36865;&#36890;&#30693;<\/h4>\n<p>&#19968;&#26086;&#20320;&#26377;&#20102;WebPush&#26381;&#21153;&#65292;&#23601;&#21487;&#20197;&#20351;&#29992;&#23427;&#26469;&#21457;&#36865;&#36890;&#30693;&#20102;&#12290;&#36825;&#37324;&#26377;&#19968;&#20010;&#31616;&#21333;&#30340;&#26041;&#27861;&#65292;&#29992;&#20110;&#23558;&#19968;&#26465;&#28040;&#24687;&#21457;&#36865;&#21040;&#25351;&#23450;&#30340;&#24212;&#29992;&#31243;&#24207;ID&#12290;<\/p>\n<pre><code class=\"language-php\">use PusherPusher;\n\n$pusher = new Pusher(\n    'YOUR_APP_ID',\n    'YOUR_KEY',\n    'YOUR_SECRET',\n    [\n        'cluster' =&gt; 'eu',\n    ]\n);\n\n$message = 'Hello from ExampleApp!';\n\n$response = $pusher-&gt;send(\n    $message,\n    ['application_id' =&gt; $pushService-&gt;id]\n);\n\nif (isset($response['error'])) {\n    echo \"Error sending notification: \" . $response['error'];\n} else {\n    echo \"Notification sent successfully.\";\n}<\/code><\/pre>\n<p>&#36825;&#20010;&#20363;&#23376;&#23637;&#31034;&#20102;&#22914;&#20309;&#21019;&#24314;&#19968;&#20010;WebPush&#26381;&#21153;&#24182;&#20351;&#29992;&#23427;&#21457;&#36865;&#28040;&#24687;&#12290;&#27880;&#24847;&#65292;&#20320;&#38656;&#35201;&#26367;&#25442;<code>YOUR_APP_ID<\/code>, <code>YOUR_KEY<\/code>, &#21644; <code>YOUR_SECRET<\/code>&#20026;&#23454;&#38469;&#30340;APIClient ID&#12289;&#31169;&#26377;&#23494;&#38053;&#21644;&#31192;&#23494;&#23494;&#38053;&#12290;&#27492;&#22806;&#65292;&#30830;&#20445;&#36825;&#20123;&#20540;&#24050;&#20174;&#20320;&#30340;&#39033;&#30446;&#20013;&#33719;&#21462;&#24182;&#27491;&#30830;&#37197;&#32622;&#12290;<\/p>\n<h3>&#24635;&#32467;<\/h3>\n<p>Web Push Notifications&#26159;&#19968;&#31181;&#24378;&#22823;&#30340;&#24037;&#20855;&#65292;&#21487;&#20197;&#24110;&#21161;&#20320;&#22312;&#26080;&#38656;&#19979;&#36733;&#26032;&#24212;&#29992;&#30340;&#24773;&#20917;&#19979;&#65292;&#21521;&#29992;&#25143;&#25552;&#20379;&#23454;&#26102;&#26356;&#26032;&#21644;&#26381;&#21153;&#12290;&#36890;&#36807;&#19978;&#36848;&#31034;&#20363;&#20195;&#30721;&#65292;&#20320;&#21487;&#20197;&#24320;&#22987;&#26500;&#24314;&#33258;&#24049;&#30340;Web Push&#26381;&#21153;&#65292;&#20174;&#32780;&#23454;&#29616;&#26356;&#20016;&#23500;&#30340;&#29992;&#25143;&#20307;&#39564;&#12290;<\/p>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>&#20889; Bug&#24037;&#31243;&#24072;&#65306; Web&#25512;&#36865;&#36890;&#30693;&#31616;&#20171; Web&#25512;&#36865;&#36890;&#30693;&#26159;&#19968;&#31181;&#038;#25..<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[49,50],"tuisongtax":[],"class_list":["post-908","post","type-post","status-publish","format-standard","hentry","category-wpdt","tag-rmzn","tag-xsbdtj"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/posts\/908","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/comments?post=908"}],"version-history":[{"count":0,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/posts\/908\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/media?parent=908"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/categories?post=908"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/tags?post=908"},{"taxonomy":"tuisongtax","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/tuisongtax?post=908"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}