简体   繁体   中英

403 forbidden when redirect to external link by php

I have code that get the playlist link through the page source Then redirects to this playlist link Through this php file run the playlist on the vlc program by user ageint He worked without problems but now shows me 403 forbidden image https://i.postimg.cc/7Yw1Fs2f/image.png

Even though I copy the link to the playlist and put it directly inside vlc with user ageint , Works without any problems.. image https://i.postimg.cc/RVd1477G/image.png

Please help me in checking the code

<?php
$html = file_get_contents("http://wssfree.com/WSSphp/wssbeinsports1/wssbeinsports1.php");

preg_match_all(
     '/(http.*?wmsAuthSign\=[^\&\">]+)/',

    $html,
    $posts, // will contain the article data
    PREG_SET_ORDER // formats data into an array of posts
);

foreach ($posts as $post) {
    $link = $post[0];

header('Location:' .$link);
exit;

}
?>

and user agent = freeapppsss

Try this to get the HTML code:

<?php

$url = "http://wssfree.com/WSSphp/wssbeinsports1/wssbeinsports1.php";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
$html = curl_exec($curl);
curl_close($curl);

echo '<textarea>'.$html.'</textarea>';

You can then use the variable $html to pull out the URL you want.

I do note that that you have a for loop that has an exit(); command for each item, which will kill the PHP page, so you don't need preg_match_all , just preg_match .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM