{"id":3734,"date":"2025-06-12T03:49:47","date_gmt":"2025-06-11T19:49:47","guid":{"rendered":"https:\/\/www.zhaozhao123.cn\/wpcms\/wpdt\/3734.html"},"modified":"2025-06-12T03:49:47","modified_gmt":"2025-06-11T19:49:47","slug":"%e5%a6%82%e4%bd%95%e5%b0%86-google-drive-%e8%bf%9e%e6%8e%a5%e5%88%b0%e6%82%a8%e7%9a%84-wordpress-%e5%aa%92%e4%bd%93%e5%ba%93","status":"publish","type":"post","link":"https:\/\/www.zhaozhao123.cn\/wpcms\/post\/3734.html","title":{"rendered":"\u5982\u4f55\u5c06 Google Drive \u8fde\u63a5\u5230\u60a8\u7684 WordPress \u5a92\u4f53\u5e93"},"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>&#35201;&#23558; Google Drive &#36830;&#25509;&#21040;&#24744;&#30340; WordPress &#23186;&#20307;&#24211;&#65292;&#35831;&#25353;&#29031;&#20197;&#19979;&#27493;&#39588;&#25805;&#20316;&#65306;<\/p>\n<ol>\n<li>\n<p>&#39318;&#20808;&#65292;&#30830;&#20445;&#24744;&#24050;&#32463;&#23433;&#35013;&#20102; Google API &#24211;&#12290;&#22914;&#26524;&#24744;&#36824;&#27809;&#26377;&#23433;&#35013;&#65292;&#35831;&#35775;&#38382; <a href=\"https:\/\/www.zhaozhao123.cn\/skin\/go?url=aHR0cHM6Ly93b3JkcHJlc3Mub3JnL3BsdWdpbnMvZ29vZ2xlLWFwaS8=\" rel=\"noopener noreferrer nofollow\">https:\/\/wordpress.org\/plugins\/google-api\/<\/a> &#24182;&#26681;&#25454;&#24744;&#30340;&#38656;&#27714;&#36873;&#25321;&#36866;&#21512;&#30340;&#25554;&#20214;&#12290;<\/p>\n<\/li>\n<li>\n<p>&#23433;&#35013;&#24182;&#28608;&#27963;&#35813;&#25554;&#20214;&#21518;&#65292;&#24744;&#38656;&#35201;&#21019;&#24314;&#19968;&#20010;&#26032;&#30340;&#24212;&#29992;&#26469;&#33719;&#21462; API &#23494;&#38053;&#12290;&#35831;&#35775;&#38382; <a href=\"https:\/\/www.zhaozhao123.cn\/skin\/go?url=aHR0cHM6Ly9jb25zb2xlLmRldmVsb3BlcnMuZ29vZ2xlLmNvbS9hcGlz\" rel=\"noopener noreferrer nofollow\">https:\/\/console.developers.google.com\/apis<\/a> &#20197;&#21551;&#21160; Google &#36134;&#25143;&#21644;&#24320;&#21457;&#32773;&#25511;&#21046;&#21488;&#12290;<\/p>\n<\/li>\n<li>\n<p>&#22312;&#24320;&#21457;&#32773;&#25511;&#21046;&#21488;&#19978;&#65292;&#28857;&#20987; &#8220;Credentials&#8221; &#26631;&#31614;&#39029;&#65292;&#28982;&#21518;&#28857;&#20987; &#8220;Create credentials&#8221; &#19979;&#25289;&#33756;&#21333;&#20013;&#30340; &#8220;API key&#8221;&#65292;&#36825;&#23558;&#20026;&#24744;&#29983;&#25104;&#19968;&#20010; API &#23494;&#38053;&#12290;&#35831;&#27880;&#24847;&#65292;&#27492;&#23494;&#38053;&#20165;&#20379;&#24320;&#21457;&#20154;&#21592;&#20351;&#29992;&#65292;&#19981;&#35201;&#23558;&#20854;&#27844;&#38706;&#32473;&#20182;&#20154;&#12290;<\/p>\n<\/li>\n<li>\n<p>&#23558;&#29983;&#25104;&#30340; API &#23494;&#38053;&#28155;&#21152;&#21040;&#24744;&#30340; WordPress &#31449;&#28857;&#20013;&#12290;&#24744;&#21487;&#20197;&#22312;&#25554;&#20214;&#35774;&#32622;&#39029;&#38754;&#25214;&#21040;&#27492;&#36873;&#39033;&#12290;<\/p>\n<\/li>\n<li>\n<p>&#21551;&#21160;&#25554;&#20214;&#24182;&#37197;&#32622;&#24517;&#35201;&#30340;&#35774;&#32622;&#12290;&#20363;&#22914;&#65292;&#24744;&#21487;&#20197;&#36873;&#25321;&#19978;&#20256;&#25991;&#20214;&#30340;&#26435;&#38480;&#12289;&#25991;&#20214;&#26684;&#24335;&#20197;&#21450;&#26159;&#21542;&#20801;&#35768;&#29992;&#25143;&#36890;&#36807;&#31038;&#20132;&#23186;&#20307;&#30331;&#24405;&#12290;<\/p>\n<\/li>\n<li>\n<p>&#27492;&#26102;&#65292;Google Drive &#24050;&#25104;&#21151;&#36830;&#25509;&#21040;&#24744;&#30340; WordPress &#23186;&#20307;&#24211;&#12290;&#29992;&#25143;&#29616;&#22312;&#21487;&#20197;&#19978;&#20256;&#25991;&#20214;&#21040; Google Drive &#20013;&#65292;&#24182;&#36890;&#36807; WordPress &#30340;&#23186;&#20307;&#24211;&#26597;&#30475;&#36825;&#20123;&#25991;&#20214;&#12290;<\/p>\n<\/li>\n<\/ol>\n<p>&#19979;&#38754;&#26159;&#31034;&#20363;&#20195;&#30721;&#65292;&#23637;&#31034;&#22914;&#20309;&#20351;&#29992; Google API &#25554;&#20214;&#19978;&#20256;&#25991;&#20214;&#21040; Google Drive&#65306;<\/p>\n<pre><code class=\"language-php\">&lt;?php\n\n\/\/ &#33719;&#21462; API &#23494;&#38053;\n$api_key = 'YOUR_API_KEY';\n\n\/\/ &#21019;&#24314; Google API &#23458;&#25143;&#31471;&#23545;&#35937;\n$client = new Google_Client();\n$client-&gt;setApplicationName('My App');\n$client-&gt;setScopes(Google_Service_Drive::DRIVE);\n$client-&gt;setAuthConfig('path\/to\/client_secrets.json');\n\n\/\/ &#20351;&#29992; API &#23494;&#38053;&#21021;&#22987;&#21270;&#23458;&#25143;&#31471;\n$client-&gt;setAssertionDetails(\n    new Google_AssertionDetails(\n        $client-&gt;getAssertionCallback(),\n        'urn:ietf:params:oauth:grant-type:jwt-bearer',\n        [\n            'aud' =&gt; 'https:\/\/www.googleapis.com\/auth\/drive',\n            'kid' =&gt; 'YOUR_PRIVATE_KEY_ID'\n        ]\n    )\n);\n\n\/\/ &#21021;&#22987;&#21270;&#26381;&#21153;&#23545;&#35937;\n$service = new Google_Service_Drive($client);\n\n\/\/ &#25351;&#23450;&#35201;&#19978;&#20256;&#30340;&#25991;&#20214;&#36335;&#24452;\n$file_path = '\/path\/to\/local\/file.txt';\n\n\/\/ &#21019;&#24314;&#26032;&#30340; Google &#25991;&#20214;\n$body = array(\n    'parents' =&gt; array('[{\"kind\":\"drive#file\",\"id\":\"0BwTgVqzXh7yZdJUxMl9aQmNtYUE\"}]'),\n    'name' =&gt; basename($file_path),\n    'mimeType' =&gt; 'text\/plain',\n);\n\ntry {\n    \/\/ &#21457;&#36865; POST &#35831;&#27714;&#19978;&#20256;&#25991;&#20214;\n    $media_body = new Google_Sheets_MediaFileUpload(file_get_contents($file_path), strlen(file_get_contents($file_path)));\n    $result = $service-&gt;files-&gt;create($body, $media_body);\n} catch (Exception $e) {\n    echo 'An error occurred: ' . $e-&gt;getMessage();\n}\n\n?&gt;<\/code><\/pre>\n<p>&#27880;&#24847;&#65306;&#19978;&#36848;&#20195;&#30721;&#20165;&#20316;&#20026;&#31034;&#20363;&#65292;&#23454;&#38469;&#20351;&#29992;&#26102;&#21487;&#33021;&#38656;&#35201;&#26681;&#25454;&#23454;&#38469;&#24773;&#20917;&#35843;&#25972;&#12290;&#27492;&#22806;&#65292;&#24744;&#38656;&#35201;&#26681;&#25454;&#33258;&#24049;&#30340;&#24773;&#20917;&#36827;&#34892;&#36866;&#24403;&#30340;&#20462;&#25913;&#65292;&#21253;&#25324;&#26367;&#25442; API &#23494;&#38053;&#21644;&#26412;&#22320;&#25991;&#20214;&#36335;&#24452;&#31561;&#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<p>Google Drive &#26159;&#19968;&#31181;&#38750;&#24120;&#24378;&#22823;&#30340;&#25991;&#20214;&#23384;&#20648;&#21644;&#21327;&#20316;&#24179;&#21488;&#65292;&#23427;&#25552;&#20379;&#20102;&#22810;&#31181;&#26041;&#24335;&#26469;&#36830;&#25509;&#21040; WordPress &#23186;&#20307;&#24211;&#12290;&#20197;&#19979;&#26159;&#19968;&#20123;&#22522;&#26412;&#27493;&#39588;&#65306;<\/p>\n<ol>\n<li>\n<p><strong>&#21019;&#24314; Google &#20113;&#31471;&#30828;&#30424;&#65288;Drive&#65289;<\/strong>&#65306;&#39318;&#20808;&#65292;&#24744;&#38656;&#35201;&#30331;&#24405;&#21040; Google &#38463;&#37324;&#20113;&#26381;&#21153;&#22120;&#25511;&#21046;&#21488;&#24182;&#21019;&#24314;&#19968;&#20010;&#26032;&#30340; Google &#20113;&#31471;&#30828;&#30424;&#12290;&#36825;&#21487;&#20197;&#30830;&#20445;&#24744;&#26377;&#19968;&#20010;&#23433;&#20840;&#12289;&#21487;&#38752;&#30340;&#25991;&#20214;&#23384;&#20648;&#20301;&#32622;&#12290;<\/p>\n<\/li>\n<li>\n<p><strong>&#37197;&#32622; WordPress Media Library<\/strong>&#65306;&#22312; WordPress &#20013;&#35774;&#32622;&#23186;&#20307;&#24211;&#20197;&#20801;&#35768;&#19978;&#20256;&#26469;&#33258; Google Drive &#30340;&#25991;&#20214;&#12290;&#35201;&#23454;&#29616;&#36825;&#19968;&#28857;&#65292;&#24744;&#21487;&#20197;&#20351;&#29992;&#25554;&#20214;&#25110;&#33258;&#23450;&#20041;&#21151;&#33021;&#12290;&#36825;&#37324;&#25105;&#20204;&#20351;&#29992;&#19968;&#20010;&#21517;&#20026; &#8220;Google Drive Upload Plugin&#8221; &#30340;&#20813;&#36153;&#25554;&#20214;&#20026;&#20363;&#12290;<\/p>\n<\/li>\n<li>\n<p><strong>&#23433;&#35013;&#21644;&#28608;&#27963;&#25554;&#20214;<\/strong>&#65306;<\/p>\n<ul>\n<li>&#30331;&#24405;&#21040; WordPress &#25511;&#21046;&#21488;&#12290;<\/li>\n<li>&#25171;&#24320;&ldquo;&#25554;&#20214;&rdquo;&#33756;&#21333;&#65292;&#28857;&#20987;&ldquo;&#28155;&#21152;&#26032;&#25554;&#20214;&rdquo;&#25353;&#38062;&#12290;<\/li>\n<li>&#22312;&#25628;&#32034;&#26694;&#20013;&#36755;&#20837; &ldquo;Google Drive Upload Plugin&rdquo;&#65292;&#25214;&#21040;&#24182;&#23433;&#35013;&#35813;&#25554;&#20214;&#12290;<\/li>\n<li>&#21368;&#36733;&#40664;&#35748;&#30340;&ldquo;Media Upload&rdquo;&#25554;&#20214;&#65288;&#22914;&#26524;&#24744;&#24050;&#32463;&#23433;&#35013;&#20102;&#36825;&#20010;&#25554;&#20214;&#65289;&#65292;&#28982;&#21518;&#21551;&#29992;&#26032;&#30340;&ldquo;Google Drive Upload Plugin&rdquo;&#12290;<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>&#37197;&#32622;&#25554;&#20214;<\/strong>&#65306;<\/p>\n<ul>\n<li>&#28857;&#20987;&ldquo;&#25554;&#20214;&#31649;&#29702;&rdquo;&#39029;&#38754;&#19978;&#30340;&ldquo;Google Drive Upload Plugin&rdquo;&#65292;&#25171;&#24320;&#25554;&#20214;&#35774;&#32622;&#30028;&#38754;&#12290;<\/li>\n<li>&#22312;&ldquo;&#39537;&#21160;&#22120;&#21517;&#31216;&rdquo;&#23383;&#27573;&#20013;&#22635;&#20889;&#24744;&#30340; Google &#20113;&#31471;&#30828;&#30424;&#30340;&#21517;&#31216;&#12290;<\/li>\n<li>&#22312;&ldquo;API Key&rdquo;&#23383;&#27573;&#20013;&#36755;&#20837;&#24744;&#20174; Google &#38463;&#37324;&#20113;&#26381;&#21153;&#22120;&#25511;&#21046;&#21488;&#33719;&#21462;&#30340; API &#23494;&#38053;&#12290;<\/li>\n<li>&#35774;&#32622;&#20854;&#20182;&#36873;&#39033;&#65292;&#22914;&ldquo;&#26159;&#21542;&#26174;&#31034;&#38142;&#25509;&rdquo;&#12289;&ldquo;&#26159;&#21542;&#26174;&#31034;&#22823;&#23567;&rdquo;&#31561;&#12290;<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>&#27979;&#35797;&#36830;&#25509;<\/strong>&#65306;<\/p>\n<ul>\n<li>&#23581;&#35797;&#22312; Google Drive &#20013;&#36873;&#25321;&#20219;&#20309;&#25991;&#20214;&#65292;&#28982;&#21518;&#22312; WordPress &#23186;&#20307;&#24211;&#20013;&#23581;&#35797;&#19978;&#20256;&#12290;<\/li>\n<li>&#22914;&#26524;&#25104;&#21151;&#65292;&#24744;&#24212;&#35813;&#20250;&#30475;&#21040;&#25991;&#20214;&#34987;&#33258;&#21160;&#28155;&#21152;&#21040;&#23186;&#20307;&#24211;&#20013;&#12290;<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>&#20445;&#23384;&#21644;&#20998;&#20139;<\/strong>&#65306;<\/p>\n<ul>\n<li>&#23558;&#25991;&#20214;&#20849;&#20139;&#32473;&#20182;&#20154;&#26102;&#65292;&#35831;&#30830;&#20445;&#20182;&#20204;&#22312; WordPress &#23186;&#20307;&#24211;&#20013;&#26377;&#26435;&#38480;&#35775;&#38382;&#36825;&#20123;&#25991;&#20214;&#12290;<\/li>\n<li>&#21487;&#20197;&#36890;&#36807;&#35774;&#32622;&#29992;&#25143;&#32452;&#25110;&#32773;&#29992;&#25143;&#26435;&#38480;&#26469;&#38480;&#21046;&#26576;&#20123;&#29992;&#25143;&#30340;&#35775;&#38382;&#26435;&#38480;&#12290;<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>&#25193;&#23637;&#21151;&#33021;<\/strong>&#65306;<\/p>\n<ul>\n<li>&#32771;&#34385;&#20026;&#24744;&#30340;&#32593;&#31449;&#28155;&#21152;&#26356;&#22810;&#30340; Google Drive &#21151;&#33021;&#65292;&#20363;&#22914;&#21019;&#24314; Google &#30005;&#23376;&#20070;&#65292;&#19982; Google Docs &#26080;&#32541;&#38598;&#25104;&#31561;&#12290;<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>&#35831;&#27880;&#24847;&#65292;&#30001;&#20110;&#19981;&#21516;&#30340; WordPress &#20027;&#39064;&#21644;&#25554;&#20214;&#21487;&#33021;&#26377;&#19981;&#21516;&#30340;&#24037;&#20316;&#27969;&#31243;&#21644;&#37197;&#32622;&#26041;&#27861;&#65292;&#25152;&#20197;&#20197;&#19978;&#25805;&#20316;&#20165;&#20379;&#21442;&#32771;&#12290;&#22312;&#23454;&#38469;&#24212;&#29992;&#20013;&#65292;&#21487;&#33021;&#20250;&#36935;&#21040;&#19968;&#20123;&#29305;&#23450;&#30340;&#38382;&#39064;&#65292;&#22240;&#27492;&#24314;&#35758;&#24744;&#20180;&#32454;&#38405;&#35835;&#25554;&#20214;&#30340;&#24110;&#21161;&#25991;&#26723;&#65292;&#24182;&#26681;&#25454;&#33258;&#24049;&#30340;&#38656;&#27714;&#36827;&#34892;&#35843;&#25972;&#21644;&#20248;&#21270;&#12290;<\/p>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Bug&#32534;&#35793;&#29422; &#35201;&#23558; Google Drive &#36830;&#25509;&#21040;&#24744;&#30340; WordPress &#23186;&#20307;&#24211;&#65292;&#35831;&#25353;&#038;#2..<\/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":[2107,2106],"tuisongtax":[],"class_list":["post-3734","post","type-post","status-publish","format-standard","hentry","category-wpdt","tag-cjyy","tag-cjzn"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/posts\/3734","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=3734"}],"version-history":[{"count":0,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/posts\/3734\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/media?parent=3734"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/categories?post=3734"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/tags?post=3734"},{"taxonomy":"tuisongtax","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/tuisongtax?post=3734"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}