file-get-contents

file_get_contents(): php_network_getaddresses: getaddrinfo failed

爱⌒轻易说出口 提交于 2019-12-04 00:42:00
I'm trying to update some values from one server to another server with a cron job. I use file_get_contents(). The strange thing is that this fails occasionally. One minute it works, another minute it won't work. I receive these two errors: PHP Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known PHP Warning: file_get_contents(): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known and: PHP Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: No address associated with hostname PHP

PHP - Safe way to download large files?

你说的曾经没有我的故事 提交于 2019-12-03 21:13:57
Information There are many ways to download files in PHP, file_get_contents + file_put_contents , fopen , readfile and cURL. Question? When having a large file, let's say 500 MB from another server / domain, what is the "correct" way to downloaded it safe? If connection failes it should find the position and continue OR download the file again if it contains errors. It's going to be used on a web site, not in php.exe shell. What I figured out so far I've read about AJAX solutions with progress bars but what I'm really looking for is a PHP solution. I don't need to buffer the file to a string

Using proxy with file_get_contents

浪尽此生 提交于 2019-12-03 16:36:58
I am getting data for my application from a website, say x.com. I use the php function file_get_contents() to fetch the data. It is sure that , my server's ip address will be shown in x.com 's logs. Is there any way to hide my server's ip without using proxy? If I have a proxy ,how to use it with file_get_contents() ? I need to send the request in both HTTP POST and HTTP GET methods test.php using http://ifconfig.me/ip code modified from http://www.php.net/manual/en/function.file-get-contents.php <?php // Create a stream $opts = array( 'http'=>array( 'method'=>"GET", 'header'=>"Accept-language

Posting a file to a web service with Guzzle

佐手、 提交于 2019-12-03 15:35:07
I've been trying for several hours to make a POST request that sends a file. First tried a simple file_get_contents() with stream context, doesn't seem to work. I never get a response back while the GET on a different URL works. I searched on the web for an HTTP client and found Guzzle which was downloaded 400k times on Packagist; I decided to try out this technology. Well documented but, alas, getting an error also when posting that damn file. $request = $client ->post('/files/') ->addPostFields(array('comments' => 'no value')) ->addPostFile('file', 'test.doc') ->setAuth($this->username,

Elastic search and Codeigniter (PHP)

核能气质少年 提交于 2019-12-03 13:23:20
I'm trying using ElasticSearch with Codeigniter framework. What i did is just install ElasticSearch and copyed ( :P ) a good PHP library found on the web to CI libraries: class Elasticsearch { public $config_file = 'elasticsearch'; public $index; function __construct($index = false){ $CI =& get_instance(); $CI->config->load($this->config_file); $this->server = $CI->config->item('es_server'); } function call($path, $http = array()){ if (!$this->index) throw new Exception('$this->index needs a value'); return json_decode(file_get_contents($this->server . '/' . $this->index . '/' . $path, NULL,

How to get MIME-type of an image with file_get_contents in PHP

筅森魡賤 提交于 2019-12-03 11:34:00
问题 I need to get the MIME type of an image, but I only have the body of the image which I've got with file_get_contents . Is there a possibility to get the MIME type? 回答1: Yes, you can get it like this. $file_info = new finfo(FILEINFO_MIME_TYPE); $mime_type = $file_info->buffer(file_get_contents($image_url)); echo $mime_type; 回答2: Be very careful what you do by checking only the Mime Type! If you really want to be sure that an image is actually an image, the safest way to do this is open it with

file_get_contents works on Local but not on server [duplicate]

前提是你 提交于 2019-12-03 09:57:06
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: file_get_contents() error Working on a script that connects to Instagram API to get photos from a certain tag. It works just fine on Local but on the server i get errors. Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /storage/content/91/103391/instaboll.nu/public_html/instagram.php on line 19. This is how line 19 looks: $contents = file_get

PHP - how to get main HTML content like Reader Mode in Firefox

妖精的绣舞 提交于 2019-12-03 09:10:39
in android Firefox app and safari iPad we can read only main content by "Reader Mode". read more... How to recognize only main content in HTML with PHP? I need to detect main news like Firefox or safari by php for example I get news from bbcsite.com/news/123 by this code: <?php $html = file_get_contents('http://bbcsite.com/news/123'); ?> then show only main news without ads and ... like Firefox and safari. I find fivefilters.org . this site can get content!!! thank you A new PHP library named PHP Goose seems to do a very good job at this too. It's pretty easy to use and is Composer friendly.

file_get_contents (or curl, or fopen) problem with session data

人走茶凉 提交于 2019-12-03 08:58:54
i have a page that shows a value from session, lets call it www.domain-a.com/master.php and if i type it directly from the browser, it shows me the session value. but when i try to download it with file_get_contents (or other method) from another domain, like www.domain-b.com/slave.php, it is not retrieving the content protected by the session, just a blank page. i know it is because the server-b is trying to retrieve the content, not the user... anyone knows how to tell the domain-a that who is retrieving the information is the user? there is a way to retrieve the session value? regards, josé

Download YouTube video in server

依然范特西╮ 提交于 2019-12-03 04:57:59
I have created a YouTube search engine + download + MP3 convert script. I have used Jeckman's YouTube Downloader for creating this script. Everything is OK, except, I want to download the video into the server instead it downloading it to my computer. I want to do this because, after it gets download, I shall convert the video to MP3 using FFmpeg. Is there any way to get the video downloaded in my server instead of my computer? The download.php contains the following code: <?php // Check download token if (empty($_GET['mime']) OR empty($_GET['token'])) { exit('Invalid download token 8{'); } //