php 在代码点火器中卷曲
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19954514/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Curl in codeigniter
提问by chirag
I want to use curl in my codeigniter application. But I am getting null array.
我想在我的 codeigniter 应用程序中使用 curl。但我得到空数组。
My code is like this:
我的代码是这样的:
$this->load->library('curl');
$url = "http://url/checkweb.php";
$post_data = array (
"foo" => "bar",
"query" => "Nettuts",
"action" => "Submit"
);
$output = $this->curl->simple_post($url, $post_data);
checkweb.php
:
checkweb.php
:
print_r($_POST);
now actually I want to pass current url and it will check that its in my private database and if it is there then its ok else it will redirect to google.com because my code can't be copied on other domain
现在实际上我想传递当前的 url,它会检查它是否在我的私人数据库中,如果它在那里,那么它就可以了,否则它将重定向到 google.com,因为我的代码无法复制到其他域
回答by Ben Fortune
If you're using the cURL library, you should have this at the bare minimum.
如果您使用的是 cURL 库,那么您应该至少拥有它。
$this->load->library('curl');
$url = "http://url/checkweb.php";
$post_data = array (
"foo" => "bar",
"query" => "Nettuts",
"action" => "Submit"
);
$output = $this->curl->simple_post($url, $post_data);
回答by Glavi?
URL passed to cURL
should be absolute-full-with-domain.
传递给的 URLcURL
应该是绝对完整的域。
Instead of:
代替:
$url = "url/checkweb.php";
try:
尝试:
$url = "http://yourdomain.com/url/checkweb.php";