{"id":2462,"date":"2025-06-11T02:40:19","date_gmt":"2025-06-10T18:40:19","guid":{"rendered":"https:\/\/www.zhaozhao123.cn\/wpcms\/wpdt\/2462.html"},"modified":"2025-06-11T02:40:20","modified_gmt":"2025-06-10T18:40:20","slug":"%e5%a6%82%e4%bd%95%e5%b0%86%e4%bb%bb%e4%bd%95wordpress%e8%a1%a8%e5%8d%95%e8%bf%9e%e6%8e%a5%e5%88%b0google%e8%a1%a8%e5%8d%95%ef%bc%88%e7%ae%80%e6%98%93%e6%96%b9%e6%b3%95%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.zhaozhao123.cn\/wpcms\/post\/2462.html","title":{"rendered":"\u5982\u4f55\u5c06\u4efb\u4f55WordPress\u8868\u5355\u8fde\u63a5\u5230Google\u8868\u5355\uff08\u7b80\u6613\u65b9\u6cd5\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<figure class=\"wp-block-image size-thumbnail is-resized is-style-rounded is-style-rounded--1\"><img decoding=\"async\" src=\"https:\/\/www.zhaozhao123.cn\/myitems\/images\/sites16\/2025\/06\/dyA-1-400x300.jpg\" alt=\"Bug&#32534;&#35793;&#29422;\" class=\"wp-image-1842\" style=\"object-fit:cover;width:30px;height:30px\"><\/figure>\r\n\r\n\r\n\r\n<p class=\"my-0\">Bug&#32534;&#35793;&#29422;<\/p>\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<p>&#20026;&#20102;&#23558;&#24744;&#30340;WordPress&#34920;&#21333;&#19982;Google&#34920;&#21333;&#36830;&#25509;&#36215;&#26469;&#65292;&#24744;&#21487;&#20197;&#20351;&#29992;&#19968;&#20123;&#25554;&#20214;&#21644;API&#26469;&#23454;&#29616;&#36825;&#20010;&#21151;&#33021;&#12290;&#36825;&#37324;&#25105;&#20204;&#20171;&#32461;&#19968;&#31181;&#31616;&#20415;&#30340;&#26041;&#27861;&#65292;&#36890;&#36807;&#20351;&#29992;Google Sheets API&#26469;&#22788;&#29702;&#34920;&#21333;&#25968;&#25454;&#12290;<\/p>\n<h3>&#27493;&#39588; 1: &#23433;&#35013;Google Sheets API&#25554;&#20214;<\/h3>\n<p>&#39318;&#20808;&#65292;&#22312;&#24744;&#30340;WordPress&#21518;&#21488;&#30340;&ldquo;&#25554;&#20214;&rdquo;&#37096;&#20998;&#25214;&#21040;&#24182;&#23433;&#35013;&ldquo;Google Sheets API&rdquo;&#25554;&#20214;&#12290;&#36825;&#23558;&#20801;&#35768;&#24744;&#36890;&#36807;JavaScript&#35775;&#38382;Google Sheets API&#12290;<\/p>\n<h3>&#27493;&#39588; 2: &#37197;&#32622;Google Sheets API<\/h3>\n<ul>\n<li>&#30331;&#24405;&#21040;Google Cloud Console&#12290;<\/li>\n<li>&#21019;&#24314;&#19968;&#20010;&#26032;&#30340;&#39033;&#30446;&#65292;&#28982;&#21518;&#33719;&#21462;&#24212;&#29992;&#20973;&#35777;&#65288;OAuth 2.0&#23458;&#25143;&#31471;ID&#65289;&#65292;&#21253;&#25324;<code>Client ID<\/code>&#12289;<code>Client Secret<\/code>&#20197;&#21450;<code>Redirect URI<\/code>&#12290;<\/li>\n<li>&#22312;Google Sheets API&#25554;&#20214;&#30340;&#35774;&#32622;&#39029;&#38754;&#20013;&#65292;&#28155;&#21152;&#19978;&#36848;&#20449;&#24687;&#20197;&#23436;&#25104;&#37197;&#32622;&#12290;<\/li>\n<\/ul>\n<h3>&#27493;&#39588; 3: &#32534;&#20889;PHP&#33050;&#26412;<\/h3>\n<p>&#25509;&#19979;&#26469;&#65292;&#32534;&#20889;&#19968;&#20010;&#31616;&#21333;&#30340;PHP&#33050;&#26412;&#26469;&#25509;&#25910;&#34920;&#21333;&#25552;&#20132;&#30340;&#25968;&#25454;&#24182;&#23558;&#20854;&#19978;&#20256;&#21040;Google Sheets&#65306;<\/p>\n<pre><code class=\"language-php\">&lt;?php\n\/\/ &#33719;&#21462;&#34920;&#21333;&#25968;&#25454;\n$subject = $_POST['subject'];\n$message = $_POST['message'];\n\n\/\/ &#21019;&#24314;&#26032;&#30340;&#24037;&#20316;&#31807;\n$spreadsheetId = 'your_spreadsheet_id'; \/\/ &#26367;&#25442;&#20026;&#24744;&#30340;Google Sheets ID\n$range = 'Sheet1!A:B'; \/\/ &#22914;&#26524;&#27809;&#26377;&#25351;&#23450;&#33539;&#22260;&#65292;&#21017;&#40664;&#35748;&#20026;A1:A1\n\n\/\/ &#35774;&#32622;&#35831;&#27714;&#22836;\n$headers = array(\n    \"Content-Type: application\/json\",\n    \"Authorization: Bearer YOUR_ACCESS_TOKEN\"\n);\n\n\/\/ &#21457;&#36865;POST&#35831;&#27714;&#21040;Google Sheets API\n$url = \"https:\/\/sheets.googleapis.com\/v4\/spreadsheets\/{$spreadsheetId}\/values\/\". $range . \":append\";\n$response = wp_remote_post($url, array(\n    'headers' =&gt; $headers,\n    'method' =&gt; 'POST',\n    'body' =&gt; json_encode(array('values' =&gt; array([$subject, $message]))),\n));\n\n\/\/ &#26816;&#26597;&#21709;&#24212;&#29366;&#24577;&#30721;\nif (wp_remote_retrieve_response_code( $response ) != 200) {\n    echo \"Error posting data to Google Sheets.\";\n} else {\n    echo \"Data successfully posted to Google Sheets.\";\n}\n?&gt;<\/code><\/pre>\n<h3>&#27493;&#39588; 4: &#20351;&#29992;&#34920;&#21333;&#25552;&#20132;&#34920;&#21333;&#25968;&#25454;<\/h3>\n<p>&#30830;&#20445;&#24744;&#30340;&#34920;&#21333;&#26377;&#36866;&#24403;&#30340;&#38544;&#34255;&#23383;&#27573;&#29992;&#20110;&#20256;&#36882;&#25968;&#25454;&#21040;&#19978;&#36848;PHP&#33050;&#26412;&#12290;&#20363;&#22914;&#65306;<\/p>\n<pre><code class=\"language-html\">&lt;form action=\"YOUR_PHP_FILE.php\" method=\"post\"&gt;\n    &lt;label for=\"subject\"&gt;Subject:&lt;\/label&gt;\n    &lt;input type=\"text\" name=\"subject\" id=\"subject\"&gt;&lt;br&gt;&lt;br&gt;\n\n    &lt;label for=\"message\"&gt;Message:&lt;\/label&gt;\n    &lt;textarea name=\"message\" id=\"message\"&gt;&lt;\/textarea&gt;&lt;br&gt;&lt;br&gt;\n\n    &lt;button type=\"submit\"&gt;Submit&lt;\/button&gt;\n&lt;\/form&gt;<\/code><\/pre>\n<h3>&#27493;&#39588; 5: &#27979;&#35797;&#36830;&#25509;<\/h3>\n<p>&#20445;&#23384;&#34920;&#21333;&#21518;&#65292;&#28857;&#20987;&#25552;&#20132;&#25353;&#38062;&#65292;&#26816;&#26597;Google Sheets&#20013;&#30340;&#26032;&#34892;&#26159;&#21542;&#25104;&#21151;&#28155;&#21152;&#20102;&#30456;&#24212;&#30340;&#25968;&#25454;&#12290;<\/p>\n<p>&#35831;&#27880;&#24847;&#65292;&#27492;&#26041;&#27861;&#20381;&#36182;&#20110;Google Sheets API&#30340;&#26435;&#38480;&#12290;&#35831;&#26681;&#25454;&#23454;&#38469;&#24773;&#20917;&#35843;&#25972;&#30456;&#20851;&#21442;&#25968;&#65292;&#22914;<code>spreadsheetId<\/code>&#21644;<code>access_token<\/code>&#12290;&#27492;&#22806;&#65292;&#30830;&#20445;&#24744;&#30340;Google&#36134;&#25143;&#20855;&#26377;&#24517;&#35201;&#30340;&#26435;&#38480;&#25165;&#33021;&#35775;&#38382;Google Sheets&#12290;<\/p>\n<p>&#36825;&#31181;&#26041;&#27861;&#25552;&#20379;&#20102;&#31616;&#21333;&#32780;&#39640;&#25928;&#30340;&#26041;&#24335;&#26469;&#23558;WordPress&#34920;&#21333;&#38598;&#25104;&#21040;Google Sheets&#20013;&#65292;&#20174;&#32780;&#25910;&#38598;&#29992;&#25143;&#21453;&#39304;&#25110;&#35760;&#24405;&#20854;&#20182;&#30456;&#20851;&#20449;&#24687;&#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<figure class=\"wp-block-image size-thumbnail is-resized is-style-rounded is-style-rounded--2\"><img decoding=\"async\" src=\"https:\/\/www.zhaozhao123.cn\/myitems\/images\/sites16\/2025\/06\/zp-400x300.jpg\" alt=\"&#40657;&#26495;&#21069;&#30340;Bug&#35821;&#27861;&#35762;&#24072;\" class=\"wp-image-1849\" style=\"object-fit:cover;width:30px;height:30px\"><\/figure>\r\n\r\n\r\n\r\n<p class=\"my-0\">&#40657;&#26495;&#21069;&#30340;Bug&#35821;&#27861;&#35762;&#24072;<\/p>\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>&#22914;&#20309;&#23558;&#20219;&#20309;WordPress&#34920;&#21333;&#36830;&#25509;&#21040;Google&#34920;&#21333;&#65288;&#31616;&#26131;&#26041;&#27861;&#65289;<\/h3>\n<h4>&#38382;&#39064;&#25551;&#36848;<\/h4>\n<p>&#29992;&#25143;&#24076;&#26395;&#20351;&#29992;&#20182;&#20204;&#30340;WordPress&#32593;&#31449;&#19978;&#30340;&#29616;&#26377;&#34920;&#21333;&#19982;Google&#34920;&#21333;&#38598;&#25104;&#65292;&#20197;&#20415;&#20182;&#20204;&#21487;&#20197;&#36731;&#26494;&#22320;&#20174;&#19968;&#20010;&#22320;&#26041;&#31649;&#29702;&#25152;&#26377;&#34920;&#21333;&#25968;&#25454;&#12290;<\/p>\n<h4>&#35299;&#20915;&#26041;&#26696;<\/h4>\n<p>&#20026;&#20102;&#23454;&#29616;&#36825;&#20010;&#30446;&#26631;&#65292;&#25105;&#20204;&#23558;&#20351;&#29992;&#20004;&#20010;&#19981;&#21516;&#30340;&#24037;&#20855;&#65306;WordPress&#21644;Google&#34920;&#21333;API&#12290;&#39318;&#20808;&#65292;&#25105;&#20204;&#38656;&#35201;&#21019;&#24314;&#19968;&#20010;&#26032;&#30340;Google&#34920;&#21333;&#24182;&#37197;&#32622;&#23427;&#20197;&#25509;&#25910;&#26469;&#33258;WordPress&#30340;&#34920;&#21333;&#25968;&#25454;&#12290;<\/p>\n<h4>&#27493;&#39588;1: &#21019;&#24314;&#26032;&#30340;Google&#34920;&#21333;<\/h4>\n<ol>\n<li><strong>&#30331;&#24405;&#21040;&#24744;&#30340;Google&#20113;&#31471;&#26381;&#21153;&#24080;&#25143;<\/strong>&#12290;<\/li>\n<li>&#22312;Google&#20113;&#31471;&#26381;&#21153;&#20013;&#25214;&#21040;&ldquo;&#34920;&#21333;&rdquo;&#31867;&#21035;&#12290;<\/li>\n<li>&#28857;&#20987;&ldquo;&#26032;&#24314;&#34920;&#21333;&rdquo;&#65292;&#36873;&#25321;&#24744;&#24819;&#35201;&#21019;&#24314;&#30340;&#26032;&#34920;&#21333;&#31867;&#22411;&#65288;&#20363;&#22914;&#65292;&ldquo;&#30005;&#23376;&#37038;&#20214;&#36992;&#35831;&rdquo;&#25110;&ldquo;&#38382;&#21367;&#35843;&#26597;&rdquo;&#31561;&#65289;&#12290;<\/li>\n<li>&#32473;&#26032;&#34920;&#21333;&#21629;&#21517;&#65292;&#28982;&#21518;&#35774;&#32622;&#19968;&#20123;&#22522;&#26412;&#30340;&#36873;&#39033;&#65292;&#22914;&#26631;&#39064;&#12289;&#25551;&#36848;&#20197;&#21450;&#26159;&#21542;&#20801;&#35768;&#25552;&#20132;&#34920;&#21333;&#12290;<\/li>\n<\/ol>\n<h4>&#27493;&#39588;2: &#37197;&#32622;Google&#34920;&#21333;&#20197;&#25509;&#21463;&#26469;&#33258;WordPress&#30340;&#25968;&#25454;<\/h4>\n<ol>\n<li><strong>&#22312;WordPress&#19978;&#21019;&#24314;&#25554;&#20214;<\/strong>&#65306;&#22914;&#26524;&#24744;&#23578;&#26410;&#23433;&#35013;WordPress&#25554;&#20214;&#65292;&#35831;&#35775;&#38382;<a href=\"https:\/\/www.zhaozhao123.cn\/skin\/go?url=aHR0cHM6Ly93b3JkcHJlc3Mub3JnL3BsdWdpbnMv\" rel=\"noopener noreferrer nofollow\" rel=\"nofollow\">https:\/\/wordpress.org\/plugins\/<\/a> &#21644;&#25628;&#32034;&ldquo;google-forms-importer&rdquo;&#12290;&#19979;&#36733;&#24182;&#28608;&#27963;&#35813;&#25554;&#20214;&#12290;<\/li>\n<li>&#22312;WordPress&#20027;&#39064;&#30340;<code>functions.php<\/code>&#25991;&#20214;&#20013;&#28155;&#21152;&#20197;&#19979;&#20195;&#30721;&#65306;<\/li>\n<\/ol>\n<pre><code class=\"language-php\">add_action('wp_loaded', 'google_form_importer_init');\nfunction google_form_importer_init() {\n    \/\/ &#21021;&#22987;&#21270;Google Forms API&#23458;&#25143;&#31471;\n    $gform_api = new GoogleFormsApi();\n}\n\n\/\/ &#21152;&#36733;Google Forms API&#23458;&#25143;&#31471;\nclass GoogleFormsApi {\n\n    private static $_instance;\n\n    public function __construct() {\n        if (is_null(self::$_instance)) {\n            self::$_instance = $this;\n        }\n    }\n\n    public static function getInstance() {\n        return self::$_instance;\n    }\n\n    public function getForm($formData) {\n        \/\/ &#36825;&#37324;&#26159;&#22788;&#29702;Google Form&#25968;&#25454;&#30340;&#36923;&#36753;\n    }\n\n    public function getFormData($formId, $fields) {\n        \/\/ &#36825;&#37324;&#26159;&#33719;&#21462;Google Form&#25968;&#25454;&#30340;&#36923;&#36753;\n    }\n}<\/code><\/pre>\n<ol>\n<li>&#23558;&#19978;&#36848;&#20195;&#30721;&#28155;&#21152;&#21040;&#24744;&#30340;WordPress&#20027;&#39064;&#30340;<code>functions.php<\/code>&#25991;&#20214;&#20013;&#12290;<\/li>\n<li>&#28608;&#27963;&#24182;&#36816;&#34892;&#27492;&#25554;&#20214;&#20197;&#21551;&#29992;Google&#34920;&#21333;&#23548;&#20837;&#21151;&#33021;&#12290;<\/li>\n<\/ol>\n<h4>&#32467;&#35770;<\/h4>\n<p>&#36890;&#36807;&#20197;&#19978;&#27493;&#39588;&#65292;&#24744;&#21487;&#20197;&#23558;WordPress&#20013;&#30340;&#34920;&#21333;&#19982;Google&#34920;&#21333;&#36827;&#34892;&#25972;&#21512;&#65292;&#20174;&#32780;&#23454;&#29616;&#22312;&#19968;&#20010;&#22320;&#26041;&#31649;&#29702;&#25152;&#26377;&#34920;&#21333;&#25968;&#25454;&#30340;&#30446;&#30340;&#12290;&#36825;&#19981;&#20165;&#31616;&#21270;&#20102;&#31649;&#29702;&#24037;&#20316;&#27969;&#31243;&#65292;&#36824;&#20026;&#29992;&#25143;&#25552;&#20379;&#20102;&#19968;&#20010;&#26356;&#30452;&#35266;&#30340;&#26041;&#24335;&#26469;&#35775;&#38382;&#21644;&#26356;&#26032;&#20182;&#20204;&#30340;&#25968;&#25454;&#12290;<\/p>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Bug&#32534;&#35793;&#29422; &#20026;&#20102;&#23558;&#24744;&#30340;WordPress&#34920;&#21333;&#19982;Google&#34920;&#21333;&#36830;&#25509;&#36215;&#26469;&#038;#652..<\/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":[59],"tuisongtax":[],"class_list":["post-2462","post","type-post","status-publish","format-standard","hentry","category-wpdt","tag-pzjc"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/posts\/2462","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=2462"}],"version-history":[{"count":0,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/posts\/2462\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/media?parent=2462"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/categories?post=2462"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/tags?post=2462"},{"taxonomy":"tuisongtax","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/tuisongtax?post=2462"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}