如何申請使用百度PCS API來讓檔案上傳到雲端
阿新 • • 發佈:2019-01-24
一:進入 http://developer.baidu.com/console#manage/apilist!
二:記錄下API Key和Secret Key
三:Server端使用百度OAuth2.0授權呼叫開放API流程
詳細文件:http://developer.baidu.com/wiki/index.php?title=docs/oauth/application
1.在瀏覽器中輸入:https://openapi.baidu.com/oauth/2.0/authorize?response_type=code&client_id={API Key}&redirect_uri=oob
2. 複製下授權碼
3. 獲取到 Access Token
在瀏覽器中輸入:
https://openapi.baidu.com/oauth/2.0/token?grant_type=authorization_code&code={Access Token}&client_id={API Key}&client_secret={Secret Key}&redirect_uri=oob
從而獲取到Access Token
輸入結果如:
http://developer.baidu.com/wiki/index.php?title=docs/pcs/guide/token_authorize
四、可以通過api操作雲盤了
文件見:http://developer.baidu.com/wiki/index.php?title=docs/pcs/rest/file_data_apis_list
舉例:在vps端獲取磁碟容量資訊
wget -O - "https://pcs.baidu.com/rest/2.0/pcs/quota?method=info&access_token={token}" 2>/dev/null