Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/239.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 与推荐人一起请求url_Php - Fatal编程技术网

Php 与推荐人一起请求url

Php 与推荐人一起请求url,php,Php,如何向URL发送请求: 在端口80上与参考 爬网源代码 我可以在PHP中使用cURL吗 $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http:// www.flashi.tv/embed.php?v=HitSportsNet41125'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_REFERER, 'http:// sportsembed.c

如何向URL发送请求: 在端口80上与参考 爬网源代码

我可以在PHP中使用cURL吗

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http:// www.flashi.tv/embed.php?v=HitSportsNet41125');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, 'http:// sportsembed.com/stream-1.php');
$html = curl_exec($ch);
我知道referer的拼写不正确,这是我们每个人都必须面对的://

是的,curl可以做到这一点

谷歌搜索php curl set referer提供了一些很好的提示:

  • 其中显示了以下示例代码:

cURL是PHP中的一个可选模块,您可能不会发现它安装在任何地方

以下是PHP核心的一部分:

$contextOptions=stream_context_create(array(
    "http"=>array(
        "method"=>"GET",
        "header"=>
            "Accept-language: en\r\n".
            "Cookie: foo=bar\r\n".
            "Referer: http://sportsembed.com/stream-1.php\r\n",
        "user_agent"=>"CrawlingBot v1.0"
    )
));
file_get_contents("http://www.flashi.tv/embed.php?v=HitSportsNet41125", /*include path*/ false, $contextOptions);

而且很容易找到-1你试过什么?你的密码在哪里?你读过手册了吗?@EmilVikström他能为这么简单的事情提供什么代码(如果你想的话,有点像一行代码)?stackexchange上的向下投票最近变得非常激进。提比略:这个讨论应该在梅塔举行,真的,但我不同意你的看法。“向下投票”按钮的工具提示上写着:“这个问题没有显示任何研究成果”,这正是我对这个问题的看法。另请参见和@emil你没有回答我的问题。他再也无法提供更多帮助我们给出更好或公正的答案。我指的是你的评论,实际上是从PHP文档页面中的一个例子中摘取的。谢谢..我已经查阅了指南..解决了..有了你的参考如果这解决了你的问题,别忘了将答案标记为已接受(投票按钮下的绿色复选标记)。
$contextOptions=stream_context_create(array(
    "http"=>array(
        "method"=>"GET",
        "header"=>
            "Accept-language: en\r\n".
            "Cookie: foo=bar\r\n".
            "Referer: http://sportsembed.com/stream-1.php\r\n",
        "user_agent"=>"CrawlingBot v1.0"
    )
));
file_get_contents("http://www.flashi.tv/embed.php?v=HitSportsNet41125", /*include path*/ false, $contextOptions);