parse專案
https://parse.com/
1.先註冊帳號,創app專案,創好後選擇該專案開始quickstart
https://www.parse.com/apps/quickstart
server端
quickstart>cloud_code > 選擇你本機的作業系統
https://www.parse.com/apps/quickstart#cloud_code/windows
Get the Parse tool
下載parse> 至環境變數加入parse.exe之目錄
Set up a Cloud Code directory
開啟命令列 cmd 執行parse new <目錄名> (會在本機創建一cloud code的目錄)
$ parse new MyCloudCode
Email: ninja@gmail.com
Password:
1:MyApp
2:MyOtherApp
Select an App: 1
$
cd
MyCloudCode
接著在本機創建的目錄下撰寫cloud code
Take a look at cloud/main.js
. You'll see an example function that just returns a string:
再部屬到parse server雲端的空間上
$ parse deploy
正確的話按下Test會出現
Congrats! You made your first deployment.
成功後繼續學習What's next?>( Run jobs when data is saved / Explore cloud modules)
https://www.parse.com/docs/tw/js/guide#cloud_code ( 加上tw即有中文版)
把範例加到cloud/main.js 內 部屬至雲端 (parse deploy) 部屬失敗會有訊息,部屬成功會有更動的版號出現
成功後可用client做呼叫測試(iOs/Android/javascript/REST/Php/curl...)
Host
選專案>setting>host>Web Hosting>__test____.parseapp.com 填你想取的名字
設定好後在本機目錄下會出現cloud/view,cloud/app.js,public/index.html
以剛才的例子:test.parseapp.com 可看到host主頁 (public/index.html)
Congratulations! You're already hosting with Parse.
http://test.parseapp.com/hello 即可看到 (cloud/app.js 內寫的hello function,其內還有註解其它使用方法)
Congrats, you just set up your app!
android
https://www.parse.com/apps/quickstart#parse_data/mobile/android/native/existing
quickstart>mobile>android>java>存在的專案
Download & unzip the SDK 下載parse對android出的sdk
可以gardle方式匯入gardle的專案或是直接開android專案,copy src下的.java檔,以及lib下的.jar
在onCreate內加入新增資料的code (相當於新增TestObject table ,欄位foo資料bar)
執行Android專案,若成功,則按下test 會列出結果
Congrats! You saved your first object:
同樣的繼續學習What's next 或至docs下Android guide有其它更多用法
https://www.parse.com/docs/android/guide
REST
https://parse.com/docs/rest/guide
配合chrome 插件 postman 可直接做api測試
可直接對classes/user/sessions/roles/files/analytics(events)/pushnotification/Installations/Cloud Functions做rest呼叫
cloud code使用rest可直接測試結果,推薦撰寫cloud code 時先行配合使用,無誤再開放android client端使用問題較少
Logs
選專案>Core>Logs
在logs內可以看到server端的存取及錯誤訊息(Info/Error)以供除錯,
也可於cloud code內埋console.log ,將log 寫於server端內不外露至client。