file-get-contents

PHP ini file_get_contents external url

浪尽此生 提交于 2019-11-25 23:49:37
问题 I use following PHP function: file_get_contents(\'http://example.com\'); Whenever I do this on a certain server, the result is empty. When I do it anywhere else, the result is whatever the page\'s content may be. When I however, on the server where the result is empty, use the function locally - without accessing an external URL ( file_get_contents(\'../simple/internal/path.html\'); ), it does work. Now, I am pretty sure it has something to do with a certain php.ini configuration. What I am

PHP file_get_contents() returns “failed to open stream: HTTP request failed!”

做~自己de王妃 提交于 2019-11-25 23:37:36
问题 I am having problems calling a url from PHP code. I need to call a service using a query string from my PHP code. If I type the url into a browser, it works ok, but if I use file-get-contents() to make the call, I get: Warning: file-get-contents(http://.... ) failed to open stream: HTTP request failed! HTTP/1.1 202 Accepted in ... The code I am using is: $query=file_get_contents(\'http://###.##.##.##/mp/get?mpsrc=http://mybucket.s3.amazonaws.com/11111.mpg&mpaction=convert format=flv\'); echo(

How to post data in PHP using file_get_contents?

三世轮回 提交于 2019-11-25 21:58:02
问题 I\'m using PHP\'s function file_get_contents() to fetch contents of a URL and then I process headers through the variable $http_response_header . Now the problem is that some of the URLs need some data to be posted to the URL (for example, login pages). How do I do that? I realize using stream_context I may be able to do that but I am not entirely clear. Thanks. 回答1: Sending an HTTP POST request using file_get_contents is not that hard, actually : as you guessed, you have to use the $context

file_get_contents() Breaks Up UTF-8 Characters

老子叫甜甜 提交于 2019-11-25 21:57:13
I am loading a HTML from an external server. The HTML markup has UTF-8 encoding and contains characters such as ľ,š,č,ť,ž etc. When I load the HTML with file_get_contents() like this: $html = file_get_contents('http://example.com/foreign.html'); It messes up the UTF-8 characters and loads Å, ¾, ¤ and similar nonsense instead of proper UTF-8 characters. How can I solve this? UPDATE: I tried both saving the HTML to a file and outputting it with UTF-8 encoding. Both doesn't work so it means file_get_contents() is already returning broken HTML. UPDATE2: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0