【发布时间】:2014-07-06 06:04:12
【问题描述】:
我迷路了,如何使用 CodeIgniter 解决以下问题 REST 客户端库 (REST)。
我尝试发送POST,webApp或者WebResourse是基于(ASP.net)的,所以思路是这样的:
getUser()
function getUser($ID){
//set config of the URL
$config = array('server' => 'http://www.example.com/app/webapp/);
//initialize
$this->rest->initialize($config);
//now here is my problem look at this Im lost, I try this but I dont understand:
$postData = '__VIEWSTATE=/DKEKCdmdaEKEKEcnaEKEqkencKJE&'.
'__EVENTVALIDATE=/DWRRKCkadjeEWWrjrDSJEJeW&'.
'buttonSearch=search&'.
'textFieldUserID='.$ID.';
$this->rest->option(CURLOPT_POSTFIELDS, $postData);
$this->rest->post('query/user.apsx');
//When run this, I use debug but NO show ERROR, this only return content html of page whitout query of user data.
$this->rest->debug();
注意:我使用库 rest 和 curl 在构造函数中命名。我用它来请求 GET 并完美地工作。但我想做 POST
$this->load->library('curl');
$this->load->library('rest');
图书馆: https://github.com/philsturgeon/codeigniter-restclient
谢谢。!!!
【问题讨论】:
-
只是为了确定,您是否尝试使用简单的 curl 请求或邮递员(chrome 扩展)发布帖子并且您得到了答案?我的意思是,你确定问题不在 REST API 服务器上吗?
-
当然..我尝试使用邮递员扩展名上的网址..这工作得很好......但我认为我的错误是:$this->rest->option(CURLOPT_POSTFIELDS, $postData);跨度>
-
好的,使用 $this->rest->debug();然后将结果粘贴到此处以了解错误是什么,:D
-
你能从 $this->rest->debug() 粘贴答案吗?
标签: php asp.net codeigniter rest curl