我想把一个URL的内容放在一个字符串和过程中.但是,我有一个问题.
我收到此错误:
Warning: file_get_contents(http://www.findchips.com/avail?part=74ls244) [function.file-get-contents]: failed to open stream: Redirection limit reached,
Run Code Online (Sandbox Code Playgroud)
我听说这是由于页面保护和标题,cookie和东西.我怎样才能覆盖它?
我也尝试过替代品,比如fread和fopen,但我想我只是不知道该怎么做.
有人可以帮我吗?
在PHP中使用file_get_contents或curl应该使用哪个来发出HTTP请求?
如果file_get_contents能完成这项工作,是否需要使用curl?使用curl似乎需要更多的线条.
例如:
卷曲:
$ch = curl_init('http://www.website.com/myfile.php');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec ($ch);
curl_close ($ch);
Run Code Online (Sandbox Code Playgroud)
的file_get_contents:
$output = file_get_contents('http://www.website.com/myfile.php'.$content);
Run Code Online (Sandbox Code Playgroud) 我有网站A,它正在向网站B的每个页面加载发送请求.B服务器在mysql中进行一些内部搜索,需要将一些数据返回给服务器A,服务器A将根据该响应显示一些内容.
在这两台服务器之间进行通信的最快方法是什么?