管理員通常需要自動化或簡化任何系統中的一般工作。 例如,在AEM中,管理使用者、安裝套件和管理OSGi搭售是通常必須完成的工作。
由於AEM所建立之Sling架構具有REST風格,因此大部分工作都可以透過URL呼叫完成。 cURL可用來執行此類URL呼叫,而且對AEM管理員而言也是有用的工具。
cURL是用於執行URL操縱的開放原始碼命令列工具。 它支援多種網際網路通訊協定,包括HTTP、HTTPS、FTPS、SCP、SFTP、TFTP、LDAP、DAP、DICT、TELNET、FILE、IMAP、POP3、SMTP和RTSP。
cURL是使用URL語法取得或傳送資料的成熟且廣泛使用的工具,最初於1997年發行。 名稱cURL原意是「請參閱URL」。
由於建立AEM的Sling架構具有REST風格,因此大部分工作都可縮減為URL呼叫,而URL呼叫可以與cURL一起執行。 使用cURL 可自動執行內容操作任務,例如啟 動頁 面、啟動工作流程以及操作任務(如包管理和管理用戶)。此外,您也可以針對AEM中的大部分工作,建立自己的cURL](/docs/experience-manager-65/sites-administering/curl.html?lang=zh-Hant#building-a-curl-ready-aem-command)命令。[
透過cURL執行的任何AEM命令都必須像任何AEM使用者一樣獲得授權。 使用cURL執行AEM命令時,會考慮所有ACL和存取權限。
cURL是macOS和部分Linux資料庫的標準部分。 但是,它適用於大多數的作業系統。 您可在https://curl.haxx.se/download.html找到最新的下載。
cURL的來源儲存庫也可在GitHub上找到。
cURL命令可針對AEM中的大部分作業建立,例如觸發工作流程、檢查OSGi組態、觸發JMX命令、建立複製代理等。
若要尋找您特定作業所需的確切命令,您必須使用瀏覽器中的開發人員工具,在您執行AEM命令時擷取對伺服器的POST呼叫。
以下步驟說明如何以在Chrome瀏覽器中建立新頁面為例。
準備您要在AEM中叫用的動作。 在這種情況下,我們已進入「建立頁面」嚮導的末尾,但尚未按一下「建立」。
啟動開發人員工具並選擇Network頁籤。 在清除控制台之前,按一下保留日誌選項。
在建立頁面精靈中按一下建立,以實際建立工作流程。
按一下右鍵生成的POST操作,然後選擇Copy -> Copy as cURL。
將cURL命令複製到文本編輯器,並從命令中刪除所有標題,該命令以-H
開頭(在下圖中以藍色突出顯示),然後添加正確的驗證參數,如-u <user>:<password>
。
通過命令行執行cURL命令並查看響應。
以下是常見管理與作業工作的AEM cURL命令清單。
以下範例假設AEM在埠4502
的localhost
上執行,並使用密碼admin
的使用者admin
。 其他命令佔位符以方括弧設定。
curl -u <user>:<password> http://<host>:<port>/crx/packmgr/service.jsp?cmd=ls
curl -u <user>:<password> -X POST http://localhost:4502/crx/packmgr/service/.json/etc/packages/mycontent.zip?cmd=create -d packageName=<name> -d groupName=<name>
curl -u <user>:<password> -X POST http://localhost:4502/crx/packmgr/service/.json/etc/packages/mycontent.zip?cmd=preview
curl -u <user>:<password> -X POST http://localhost:4502/crx/packmgr/service/console.html/etc/packages/mycontent.zip?cmd=contents
curl -X POST http://localhost:4502/crx/packmgr/service/.json/etc/packages/mycontent.zip?cmd=build
curl -u <user>:<password> -X POST http://localhost:4502/crx/packmgr/service/.json/etc/packages/mycontent.zip?cmd=rewrap
curl -u <user>:<password> -X POST -Fname=<New Name> http://localhost:4502/etc/packages/<Group Name>/<Package Name>.zip/jcr:content/vlt:definition
curl -u <user>:<password> -F cmd=upload -F force=true -F package=@test.zip http://localhost:4502/crx/packmgr/service/.json
curl -u <user>:<password> -F cmd=install http://localhost:4502/crx/packmgr/service/.json/etc/packages/my_packages/test.zip
curl -u <user>:<password> -F cmd=uninstall http://localhost:4502/crx/packmgr/service/.json/etc/packages/my_packages/test.zip
curl -u <user>:<password> -F cmd=delete http://localhost:4502/crx/packmgr/service/.json/etc/packages/my_packages/test.zip
curl -u <user>:<password> http://localhost:4502/etc/packages/my_packages/test.zip
curl -u <user>:<password> -FcreateUser= -FauthorizableId=hashim -Frep:password=hashim http://localhost:4502/libs/granite/security/post/authorizables
curl -u <user>:<password> -FcreateGroup=group1 -FauthorizableId=testGroup1 http://localhost:4502/libs/granite/security/post/authorizables
curl -u <user>:<password> -Fprofile/age=25 http://localhost:4502/home/users/h/hashim.rw.html
curl -u <user>:<password> -FcreateUser=testuser -FauthorizableId=hashimkhan -Frep:password=hashimkhan -Fprofile/gender=male http://localhost:4502/libs/granite/security/post/authorizables
curl -u <user>:<password> -FcreateUser=testuser -FauthorizableId=testuser -Frep:password=abc123 -Fmembership=contributor http://localhost:4502/libs/granite/security/post/authorizables
curl -u <user>:<password> -FaddMembers=testuser1 http://localhost:4502/home/groups/t/testGroup.rw.html
curl -u <user>:<password> -FremoveMembers=testuser1 http://localhost:4502/home/groups/t/testGroup.rw.html
curl -u <user>:<password> -Fmembership=contributor -Fmembership=testgroup http://localhost:4502/home/users/t/testuser.rw.html
curl -u <user>:<password> -FdeleteAuthorizable= http://localhost:4502/home/users/t/testuser
curl -u <user>:<password> -FdeleteAuthorizable= http://localhost:4502/home/groups/t/testGroup
有關詳細資訊,請參見備份和還原。
curl -u <user>:<password> -Faction=start http://localhost:4502/system/console/bundles/<bundle-name>
curl -u <user>:<password> -Faction=stop http://localhost:4502/system/console/bundles/<bundle-name>
curl -H "CQ-Action: Activate" -H "CQ-Handle: /content/test-site/" -H "CQ-Path: /content/test-site/" -H "Content-Length: 0" -H "Content-Type: application/octet-stream" http://localhost:4502/dispatcher/invalidate.cache
curl -H "CQ-Action: Deactivate" -H "CQ-Handle: /content/test-site/" -H "CQ-Path: /content/test-site/" -H "Content-Length: 0" -H "Content-Type: application/octet-stream" http://localhost:4502/dispatcher/invalidate.cache
curl -u <user>:<password> "http://localhost:4502/etc/replication/agents.author/publish/jcr:content.queue.json?agent=publish"
http://localhost:4502/etc/replication/agents.author/publish/jcr:content.queue.json?agent=publish
curl -X DELETE http://localhost:4502/etc/replication/agents.author/replication99 -u <user>:<password>
curl -u <user>:<password> -F "jcr:primaryType=cq:Page" -F "jcr:content/jcr:title=new-replication" -F "jcr:content/sling:resourceType=/libs/cq/replication/components/agent" -F "jcr:content/template=/libs/cq/replication/templates/agent" -F "jcr:content/transportUri=http://localhost:4503/bin/receive?sling:authRequestLogin=1" -F "jcr:content/transportUser=admin" -F "jcr:content/transportPassword={DES}8aadb625ced91ac483390ebc10640cdf"http://localhost:4502/etc/replication/agents.author/replication99
curl -u <user>:<password> -F "cmd=pause" -F "name=publish" http://localhost:4502/etc/replication/agents.author/publish/jcr:content.queue.json
curl -u <user>:<password> -F "cmd=clear" -F "name=publish" http://localhost:4502/etc/replication/agents.author/publish/jcr:content.queue.json
如需詳細資訊,請參閱社群評分與標章。
如需詳細資訊,請參閱Scoring and Badges Essentials。
有關詳細資訊,請參見MSRP - MongoDB儲存資源提供程式。
如需詳細資訊,請參閱「在AEM](/docs/experience-manager-65/sites-administering/enabling-crxde-lite.html?lang=zh-Hant)中啟用CRXDE Lite」。[
如需詳細資訊,請參閱Data Store Garbage Collection。
如需詳細資訊,請參閱選擇加入Adobe Analytics和Adobe Target。
如需詳細資訊,請參閱單一登入。
以下是AEM cURL指令的清單,以用於內容控制。
以下範例假設AEM在埠4502
的localhost
上執行,並使用密碼admin
的使用者admin
。 其他命令佔位符以方括弧設定。
curl -u <user>:<password> -X POST -F path="/content/path/to/page?lang=zh-Hant" -F cmd="activate" http://localhost:4502/bin/replicate.json
curl -u <user>:<password> -X POST -F path="/content/path/to/page?lang=zh-Hant" -F cmd="deactivate" http://localhost:4502/bin/replicate.json
curl -u <user>:<password> -F cmd=activate -F ignoredeactivated=true -F onlymodified=true -F path=/content/geometrixx http://localhost:4502/etc/replication/treeactivation.html
curl -u <user>:<password> -X POST -F cmd="lockPage" -F path="/content/path/to/page?lang=zh-Hant" -F "_charset_"="utf-8" http://localhost:4502/bin/wcmcommand
curl -u <user>:<password> -X POST -F cmd="unlockPage" -F path="/content/path/to/page?lang=zh-Hant" -F "_charset_"="utf-8" http://localhost:4502/bin/wcmcommand
curl -u <user>:<password> -F cmd=copyPage -F destParentPath=/path/to/destination/parent -F srcPath=/path/to/source/location http://localhost:4502/bin/wcmcommand
如需詳細資訊,請參閱以程式設計方式與工作流程互動。
curl -u <user>:<password> -F jcr:primaryType=sling:Folder http://localhost:4502/etc/test
curl -u <user>:<password> -F :operation=delete http://localhost:4502/etc/test/test.properties
curl -u <user>:<password> -F":operation=move" -F":applyTo=/sourceurl" -F":dest=/target/parenturl/" https://localhost:4502/content
curl -u <user>:<password> -F":operation=copy" -F":applyTo=/sourceurl" -F":dest=/target/parenturl/" https://localhost:4502/content
curl -u <user>:<password> -F"*=@test.properties" http://localhost:4502/etc/test
curl -u <user>:<password> -F"test2.properties=@test.properties" http://localhost:4502/etc/test
curl -u <user>:<password> -F "*=@test.properties;type=text/plain" http://localhost:4502/etc/test
如需詳細資訊,請參閱資產HTTP API。