Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP request failed! HTTP/1.1 416 Requested Range Not Satisfiable in php file

Tags:

php

wamp

how can i solve this error.
file_get_contents(http://www.example.com/name/j/92801): failed to open stream: HTTP request failed! HTTP/1.1 416 Requested Range Not Satisfiable in line
Here is php file code.
echo $file = file_get_contents("http://www.example.com/name/j/92801");
I am using wamp server 2.4

like image 807
Axeem Avatar asked Nov 10 '22 20:11

Axeem


1 Answers

first of all is allow_url_fopen enabled on your php.ini file? and second of all its better to use CURL heres a little function to help you

function curl($url , $ua = FALSE){
            if($ua == false){
                $ua = $_SERVER['HTTP_USER_AGENT'];
            }
            $ch = curl_init();
            curl_setopt($ch , CURLOPT_URL , $url);
            curl_setopt($ch , CURLOPT_RETURNTRANSFER , true);
            curl_setopt($ch , CURLOPT_FOLLOWLOCATION , true);
            curl_setopt($ch , CURLOPT_USERAGENT , $ua);
            return curl_exec($ch);
        }
like image 59
John Hudson Avatar answered Nov 14 '22 22:11

John Hudson