File_get_contents does not work for some pages

epiz_25358875
dymc.cf/

I have the problem that I cannot access a few pages. This is the warning code I get:

Warning: file_get_contents(https://www.youtube.com/watch?v=jNQXAC9IVRw): failed to open stream: HTTP request failed! HTTP/1.0 429 Too Many Requests
in /home/vol15_5/epizy.com/epiz_25970132/htdocs/test.php on line 19

Other sites work fine. The code I used is the following: (https://dymc.cf/test)

<?php
$opts = stream_context_create(array(
    'ssl' => array(
        'verify_peer' => false,
        'verify_peer_name' => false
    )
));

echo file_get_contents("https://forum.infinityfree.com/t/please-review-infinityfree-on-trustpilot/16476", false, $opts);
echo file_get_contents("https://stackoverflow.com/questions/4/", false, $opts);
echo file_get_contents("https://www.youtube.com/watch?v=jNQXAC9IVRw", false, $opts);

exit;
?>

Why are you trying to get file context of Youtube?

I want to extract the video description.

Does that matter?

Yes it does, you better use cUrl

*cURL

hehe

2 Likes

Eh?
I don’t care.

1 Like

The 429 status code means that something (probably YouTube) is saying that too many requests are coming from the IP address. It could be that your site, or another site on the server, is trying to load too much data from YouTube, and YouTube says it’s enough.

This is not really something that can be fixed with any kind of scripting or library.

Are you trying to access YouTube specifically from your site a lot?

1 Like

if YT blocks you due to too many requests then you need to use their YT API

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.