2012-11-20 52 views

回答

1

PUT不是通過PHP(即$ _PUT),也不是通過CodeIgniter本地處理的。有兩件事情要做:1)抓住你自己的PUT變量或者2)使用Phil Sturgeon的REST庫。

//put an associative array into $post_vars variable 
parse_str(file_get_contents("php://input"),$post_vars); 

來源:http://www.lornajane.net/posts/2008/accessing-incoming-put-data-from-php

但是,因爲你使用CodeIgniter工作,你應該使用菲爾鱘魚的圖書館,如果你不能找到一個真正的理由。它被嘗試,真實和測試,並處理所有的HTTP動詞。

https://github.com/philsturgeon/codeigniter-restserver

0

是的。由於PUT或DELETE方法缺乏一致的客戶端實現,因此標準做法是發送POST請求,並且A)使用查詢字符串參數(即?_method=PUT)或B)發送X-METHOD-OVERRIDE標頭。

(快速谷歌搜索返回此:http://www.endurasoft.com/Blog/post/X-HTTP-Method-Override.aspx

你可能會需要擴展CI_Input類知道創建操作和更新的區別。

+0

嗨蘭登斯我怎麼能解析這個反應在PHP?我試過 $ result = $ ex-> getResponse(); $ xmlObj = simplexml_load_string($ result); echo $ tracks = $ xml-> item-> company_name; 但得到空 – sree