簡單的 RESTful API in PHP

    檔案列表

    • db.sql
      用來建立示範的 Table
    • confi.php
      資料庫連接,測試資料庫為 mytest。
    • signup.php
      用來示範 POST method,新增一筆記錄。
    • info.php
      用來示範 GET method,取出一筆記錄。
    • status.php
      用來示範 PUT method,更新一筆記錄。

    Advanced REST client (Chrome Extension)

    1. 測試 POST 時
      • URL:http://xxx.xxx.xxx.xxx/signup.php
      • POST
      • Headers:空白
      • Payload:Form > 加上 name = XXXX, email=XXXXX, pwd=XXX, status=XXXX
    2. 測試 GET 時
      • URL:http://xxx.xxx.xxx.xxx/info.php?uid=2
      • GET
    3. 測試 PUT 時
      • URL:http://xxx.xxx.xxx.xxx/status.php
      • PUT
      • Headers:Form > 加上 uid=2, status=Updated

    TIPs:

    每次傳送成功,畫面最下方區塊應該會出現系統回應的輸出訊息,如果沒有出現,表示傳送失敗,例如:

    {
    status: 1
    msg: "Status updated!!."
    }

    檔案內容

    db.sql:

    reference to undefined name 'syntax' Exception of type 'MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException' was thrown. (click for details)

    confi.php:

    reference to undefined name 'syntax' Exception of type 'MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException' was thrown. (click for details)

    signup.php:

    reference to undefined name 'syntax' Exception of type 'MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException' was thrown. (click for details)

    info.php:

    reference to undefined name 'syntax' Exception of type 'MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException' was thrown. (click for details)

    status.php:

    reference to undefined name 'syntax' Exception of type 'MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException' was thrown. (click for details)
    標籤 (Edit tags)
    • No tags
    您必須 登入 才能發佈評論。
    Powered by MindTouch Core