search

Home  >  Q&A  >  body text

Using URL and refer, the content can be parsed on other GET interfaces, but using the following PHP code returns 404

Using URL and refer, the content can be parsed on the online PHP GET interface provided by other websites, and the packet can be captured directly on the web page. However, the following PHP code returns 404. Is this header written wrong?


##<?php

$url='http://interface.yy.com/hls/new/get/54880976/54880976/1200? source=wapyy&callback=jsonp2';

$refer='http://wap.yy.com';

$opt=array('http'=>array('header' =>"Referer: $refer"));

$context=stream_context_create($opt);

$html = file_get_contents($url,false, $context);

echo '<br>The following is the parsed content:';

echo '<br>';

echo $html;

?>



小马小马2333 days ago1478

reply all(2)I'll reply

  • 无忌哥哥

    无忌哥哥2018-07-11 15:57:30

    404 should be that there is a problem with the parameters in file_get_contents and the relevant page is not obtained

    reply
    0
  • 小马

    Solved, we need to add UA to the header, and then add a newline character to each item in the header. I added UA before but didn’t add a newline character. It took me a day.

    小马 · 2018-07-11 21:28:15
  • Cancelreply