【问题标题】:Concept of calling a CI framework externally from another site从另一个站点外部调用 CI 框架的概念
【发布时间】:2014-05-06 07:11:05
【问题描述】:

求助,我迷路了。

从其他站点调用 CI 框架 PHP 是什么概念? 我需要任何插件来帮助我实现它吗? 我必须使用 CI 来调用 CI,我该如何 cURL? 是POST DATA的输入数据问题吗?

我对网站进行了 cURL,但没有响应,因为我无法让 CI 控制器运行。

我尝试过 XML、字符串、JSON,但它不起作用。

我已阅读 Requests,Rest Server https://github.com/philsturgeon/codeigniter-restserver

如果有任何好的参考,请分享。

我已经使用 CURL 获得了验证码。 但是当我尝试将 postData 发布到登录页面时, 网页没有响应。我想知道控制器是否没有收到任何发布数据。

 $postdata1 = "aid=" . urlencode($log["userlogin"]) . "&apw=" . urlencode($log["passlogin"]) . "&code=" . urlencode($captcha) . "&submitlogin=Login!";

 echo $postdata1;

curl_setopt ($ch, CURLOPT_URL,"$site/index.php/admin");
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7");
curl_setopt ($ch, CURLOPT_TIMEOUT, 20);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt ($ch, CURLOPT_AUTOREFERER,1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_COOKIEJAR, getcwd() . $cookie);
curl_setopt ($ch, CURLOPT_COOKIEFILE, getcwd() . $cookie);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata1);
curl_setopt ($ch, CURLOPT_POST, 1);
$result1 = curl_exec ($ch);

curl_close($ch);

篡改数据结果:

//POSTDATA=aid=admin&apw=admin&code=1272&submitlogin=Login!

更新: 经过几个小时的干预,我终于进入了控制器功能。 curl_setopt ($ch, CURLOPT_URL,"$site/index.php/admin/login");

管理员。 php函数登录();

【问题讨论】:

    标签: php codeigniter curl


    【解决方案1】:

    好的。所以几个小时后,我设法找到了解决方案。

    我们使用什么样的方式来卷曲页面并不重要。 我正在选择上面那个旧方法。

    在 CI Controller 中调用函数。我们可以这样做。 比如我想访问登录。

    curl_setopt ($ch, CURLOPT_URL,"$site/index.php/admin/login"); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7"); curl_setopt ($ch, CURLOPT_TIMEOUT, 20); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION,1); curl_setopt ($ch, CURLOPT_AUTOREFERER,1); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_COOKIEJAR, getcwd() . $cookie); curl_setopt ($ch, CURLOPT_COOKIEFILE, getcwd() . $cookie); curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata1); curl_setopt ($ch, CURLOPT_POST, 1); $result1 = curl_exec ($ch);

    如果我想发送更多参数,只需根据Controller中的函数参数将其添加到URL即可。

    例如。

    控制器.php function editpw($adminid,$password){}

    curl_setopt ($ch, CURLOPT_URL,"$site/index.php/admin/editpw/$adminid/$password"); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7"); curl_setopt ($ch, CURLOPT_TIMEOUT, 20); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION,1); curl_setopt ($ch, CURLOPT_AUTOREFERER,1); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_COOKIEJAR, getcwd() . $cookie); curl_setopt ($ch, CURLOPT_COOKIEFILE, getcwd() . $cookie); curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata1); curl_setopt ($ch, CURLOPT_POST, 1); $result1 = curl_exec ($ch);

    你去。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-02
      • 2012-01-16
      • 1970-01-01
      • 2018-07-21
      • 1970-01-01
      相关资源
      最近更新 更多