2016-12-02 89 views
0

我能夠獲得JSON輸出,如果我在瀏覽器中鍵入http://localhost/CodeIg/index.php/quiz/user,但是如果我輸入http://localhost/CodeIg/index.php/quiz/restclient它給這個錯誤:{"status":false,"error":"Unknown method"}{「地位」:假的,「錯誤」:「未知法」}錯誤笨的RESTful API

我試過將get更改爲post,但仍然出現同樣的錯誤。

我把這個頁面https://code.tutsplus.com/tutorials/working-with-restful-services-in-codeigniter--net-8814這樣做了。

回答

0

即使我至少4年沒有使用過或甚至沒有考慮過這段代碼,但您仍然在GitHub上與我聯繫。

https://github.com/chriskacerguis/codeigniter-restserver/blob/d19dc77f03521c7a725a4555407e1e4e7a85f6e1/application/libraries/REST_Controller.php#L680

這是被觸發了錯誤的位置。在那裏拋出幾個斷點或var_dump()'s直到你看到是什麼造成了麻煩。

雖然您可能想要關閉CodeIgniter,並使用更積極的維護,如SlimPHPLumen

0

首先我希望你已經加載了rest api並創建了你的控制器測驗作爲一個api來調用,你只能創建你的函數,比如user_get或者restclient_get,並以同樣的方式訪問它們。你只需要改變你的函數名restclient restclient_get然後它會調用,而現在甚至沒有運行。