1
我使用笨REST_Controller製作API調用, 當我試圖獲得與格式調用(JSON/XML/HTML),它的工作笨休息控制器後響應爲XML格式
但是當我試着做後調用,在這裏我需要XML數據作爲結果,但它總是無法獲取XML數據。它總是隻顯示JSON數據。我在這裏分享我的問題
我的控制器的屏幕截圖是使用服務器變量CONTENT_TYPE庫使用下面的方法來檢測格式類型
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require(APPPATH.'libraries/REST_Controller.php');
class User extends REST_Controller {
public function index_post()
{
$this->response($this->post());
}
}
你必須在屏幕截圖中傳遞format = xml它顯示html – BSB
檢查[docs](https://github.com/chriskacerguis/codeigniter-restserver#content-types)。你的URL應該看起來像'http:// localhost/resume/user?format = xml'。 – Tpojka
是啊!我也試過了,它不起作用 –