搜尋
首頁CMS教程&#&按WP API和OAUTH-使用WordPress使用WordPress的WordPress

本教程演示了安裝和使用WP-API與Oauth一起使用的WP-API,oauth是一個提供類似REST的API端點的WordPress插件。 未經驗證的用戶可以讀取內容,而經過驗證的用戶(通過OAuth或Cookie)可以編寫內容。 該過程不是直觀的,因此本指南簡化了設置,假設基本終端和流浪熟悉。

WP API and OAuth - Using WordPress without WordPress

密鑰概念:

  • 該插件使用類似REST的端點進行內容訪問。 >
  • 內置的WP-API公開了WordPress內部設備,允許JSON檢索(例如,
  • )。 /wp-json/posts> oauth1處理身份驗證,需要
  • 終端命令。 注意:WordPress使用效率較低的3腿OAuth流。
  • >教程顯示了外部應用程序如何使用WordPress進行身份驗證並使用Guzzle通過API提交帖子。 wp-cli
  • >安裝:

使用宅基地改進的實例:

修改

's
git clone https://github.com/swader/homestead_improved hi_wp_github
cd hi_wp_github
sed -i '' "s@map\: \.@map\: $PWD@g" Homestead.yaml
塊:

Homestead.yaml sites(確保

在您的
sites:
    - map: test.app
      to: /home/vagrant/Code/wptest
>文件中。)

> test.app>安裝WordPress:/etc/hosts

帶有數據庫憑據

configure

。 通過您的瀏覽器訪問網站。
cd ~/Code
wget https://wordpress.org/latest.tar.gz
tar -xvzf latest.tar.gz
mv wordpress wptest
cd wptest
cp wp-config-sample.php wp-config.php

wp-config.php WP-API設置:

>通過WordPress插件管理器安裝WP-API插件(版本1.2。*或更高版本)。 安裝後,應返回JSON帖子數組。 但是,內容提交需要進一步的步驟。

/wp-json/posts

WP API and OAuth - Using WordPress without WordPress OAuth服務器設置:

安裝oauth1插件:wp-cli

curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
激活插件並生成密鑰/秘密:

cd ~/Code/wptest
git clone https://github.com/WP-API/OAuth1 wp-content/plugins/oauth-server
這將輸出OAuth身份驗證的ID,密鑰和秘密。 WordPress利用了效率較低的3腿OAuth流。

> oauth客戶端設置:
wp oauth1 add

>在您的VM中創建一個新項目(

),將新站點添加到>:>

重新提供VM(

)。 在submitter>目錄中創建Homestead.yaml

sites:
    - map: test.app
      to: /home/vagrant/Code/wptest
    - map: test2.app
      to: /home/vagrant/Code/submitter
。 帶有上一步的鑰匙填充

vagrant provision index.php安裝所需的作曲家軟件包:callback.php credentials.php submitter修改WordPresscredentials.php以允許重定向:>

git clone https://github.com/swader/homestead_improved hi_wp_github
cd hi_wp_github
sed -i '' "s@map\: \.@map\: $PWD@g" Homestead.yaml

以下各節詳細介紹了3腿OAuth Flow和API相互作用的index.php>,callback.phpmakepost.php>

。 (省略了簡潔的代碼,請參閱原始輸入以獲取完整的代碼示例。

結論:

該教程指導您與OAuth建立WP-API。雖然複雜,但本指南簡化了過程。 可以進一步改進和改進。

>

以上是WP API和OAUTH-使用WordPress使用WordPress的WordPress的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
將WordPress用作CMS的優缺點是什麼?將WordPress用作CMS的優缺點是什麼?May 03, 2025 am 12:09 AM

WordPressisapowerfulCMSwithsignificantadvantagesandchallenges.1)It'suser-friendlyandcustomizable,idealforbeginners.2)Itsflexibilitycanleadtositebloatandsecurityissuesifnotmanagedproperly.3)Regularupdatesandperformanceoptimizationsarenecessarytomainta

WordPress與其他流行的CMS平台相比如何?WordPress與其他流行的CMS平台相比如何?May 02, 2025 am 12:18 AM

WordPressExcccelineaseeandAdaptability,MakeitItiDealForBeginnersandsMallToMedium-SizedBusinesses.1)siseofuse:wordpressisuser-Frylyly.2)安全:drupalleadswithstrongsecurityfeatures.3)性能:performance:performance formation:phast offersefersefersefersefersefersefersefersefersexcellentperformanceedueTonode.sscore.jssor.jjsy.jjsy.4)4)

您可以使用WordPress構建會員網站嗎?您可以使用WordPress構建會員網站嗎?May 01, 2025 am 12:08 AM

是的,您可以使用Plypluginslikememberpress,PayMembersubScriptions,OrwooCommerceForuserManagemention,ContentAccesControl,andPaymentMenthandling.2)

WordPress是否需要編碼知識作為CMS?WordPress是否需要編碼知識作為CMS?Apr 30, 2025 am 12:03 AM

你不需要編程知識就能使用WordPress,但掌握編程可以提升體驗。 1)使用CSS和HTML可以調整主題樣式。 2)PHP知識能編輯主題文件,添加功能。 3)自定義插件和元標籤可優化SEO。 4)注意備份和使用子主題以防更新問題。

使用WordPress時的安全考慮是什麼?使用WordPress時的安全考慮是什麼?Apr 29, 2025 am 12:01 AM

TosecureaWordPresssite,followthesesteps:1)RegularlyupdateWordPresscore,themes,andpluginstopatchvulnerabilities.2)Usestrong,uniquepasswordsandenabletwo-factorauthentication.3)OptformanagedWordPresshostingorsecuresharedhostingwithawebapplicationfirewal

WordPress與其他網站構建者相比如何?WordPress與其他網站構建者相比如何?Apr 28, 2025 am 12:04 AM

WordPressExcelSoverotherWeberSiteBuilderSduetoItsflexible,可伸縮性,andopen-sourcenature.1)它'saversatilecmswithExtEnsextEnsexenSiveCustomizedOptionsVIATHEMESANDPLUGINS.2)它的alllearbutoffersbutoffersbutoffersbutoffersbutefersbuterbutfulcontrololoncemastered.3)

5個WordPress插件,供開發人員在2025年使用5個WordPress插件,供開發人員在2025年使用Apr 27, 2025 am 08:25 AM

2025年網站開發的七個必備WordPress插件 在2025年建立頂級WordPress網站需要速度,響應能力和可擴展性。 實現這種有效的實現通常取決於戰略插件的選擇。 這篇文章Highlig

您將使用WordPress做什麼?您將使用WordPress做什麼?Apr 27, 2025 am 12:14 AM

WordPresscanbeusedforvariouspurposesbeyondblogging.1)E-commerce:WithWooCommerce,itcanbecomeafullonlinestore.2)Membershipsites:PluginslikeMemberPressenableexclusivecontentareas.3)Portfoliosites:ThemeslikeAstraallowstunninglayouts.Ensuretomanageplugins

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 英文版

SublimeText3 英文版

推薦:為Win版本,支援程式碼提示!

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

WebStorm Mac版

WebStorm Mac版

好用的JavaScript開發工具

VSCode Windows 64位元 下載

VSCode Windows 64位元 下載

微軟推出的免費、功能強大的一款IDE編輯器