【问题标题】:How do I resolve POST asp with REST-client on codeIgniter如何在 codeIgniter 上使用 REST 客户端解决 POST asp
【发布时间】: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


【解决方案1】:

正如你在问题中所说:

//运行这个时,我使用debug但NO show ERROR,这个只返回 页面内容html,不包含用户数据查询。

$this->rest->debug();

因此,如果您收到了 HTML 但没有收到所需的数据,则问题出在您请求的服务器上。不仅可以确定您没有提出正确的请求,而且很奇怪,因为他们应该向您显示错误所在。

另外,你能粘贴给定的答案吗?只是想知道错误是什么,如果有的话。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-11
    • 1970-01-01
    • 2017-04-22
    • 2015-02-20
    相关资源
    最近更新 更多