file-get-contents

How can I retain indentation while using file_get_content with php?

六月ゝ 毕业季﹏ 提交于 2019-12-11 12:44:27
问题 I am using the file_get_contents function in php to get the contents of a site. The problem is that on the site I am grabbing information from, the information is neatly indented, yet when I retrieve the information it looses all indentation. The code I am using is: <?php $url = "https://graph.facebook.com/btaylor"; $file = file_get_contents($url); echo "$file"; ?> If you go to the original site here, you can see how the information is set up as: { "id": "220439", "name": "Bret Taylor",

How fix UTF-8 Characters in PHP file_get_contents()

牧云@^-^@ 提交于 2019-12-11 10:40:25
问题 When I am using file_get_contents($url) , and when I echo this, it returns an exotic character. But it can be seen only in some websites and works correctly in other websites: My code is: <?php header ( "Content-Type: text/html;charset=utf-8" ); $url ="http://www.varzesh3.com/news/1307290"; echo $go_to = file_get_contents($url); ?> 回答1: According to PHP manual: you can use this code, if you have problem with file_get_contents! <?php function file_get_contents_utf8($fn) { $content = file_get

file_get_contents for file owned by root

这一生的挚爱 提交于 2019-12-11 09:29:32
问题 I am in the process of setting up a remote backup for my MariaDB server (running on 64 bit Ubuntu 12.04). The first step in this process was easy - I am using automysqlbackup as explained here. The next step is mostly pretty easy - I am uploading the latest backup in the folder /var/lib/automysqlbackup/daily/dbname to a remote backup service (EVBackup in the present case) via SFTP. The only issue I have run into is this The files created in that folder by automysqlbackup bear names in the

Content from large number of web pages into array (PHP)

独自空忆成欢 提交于 2019-12-11 09:16:06
问题 I have an array ($x) containing 748 URL:s. Now, I want to fetch a specific part from each page and put all those parts into a new array. That is, an array containing 748 pieces of text, each from a different URL defined in array $x. Here's the code I've got so far: foreach ($x as $row) { $contents = file_get_contents($row); $regex = '/delimiter_start(.*?)delimiter_end/s'; preg_match_all($regex, $contents, $output); } If I var_dump $output I get a strange array that endlessly keeps looping

Should I use proxies with simplexml_load_file and file_get_contents?

ⅰ亾dé卋堺 提交于 2019-12-11 08:53:14
问题 I'm using simplexml_load_file to get RSS from several websites for a while. Sometimes I get errors from some of these websites and for about 5 days I'm having errors from 2 specific websites. Here are the errors from simplexml_load_file : PHP Warning: simplexml_load_file(http://example.com/feed): failed to open stream: Connection timed out PHP Warning: simplexml_load_file(): I/O warning : failed to load external entity "http://example.com/feed" Here are the errors from file_get_contents : PHP

Get Document source After AJAX or js Action With PHP

早过忘川 提交于 2019-12-11 08:42:23
问题 When I compare the source code of a webpage in the browser with the source code I get from the code below, $data = file_get_contents("http://www.someurl.com/loader.aspx"); it differs. The source code is not the same and I suspect that is caused because of some DOM manipulations. Is it possible to get the HTML source code after the javascript and/or ajax manipulations programmaticly (with PHP)? 回答1: You will need to use a headless browser that can evaluate JavaScript on the page. One very

How to include files with HTTPS - PHP

纵然是瞬间 提交于 2019-12-11 06:59:57
问题 I made a form process and broke the code up into different files to stay clean and organized. Now I am setting up the form for https security. Do all the files I pull into my page have to be called as https as well? In which case I can no longer use include(); as it no longer allows relative paths? Is the solution to use file_get_contents();? Or does only the (master) page itself need to be called as https? 回答1: It sounds like you are confusing terminology. HTTPS is the protocol used to

accessing $_SESSION when using file_get_contents in PHP

妖精的绣舞 提交于 2019-12-11 06:36:58
问题 I have a page called send.email.php which sends an email - pretty simple stuff - I pass an order id, it creates job request and sends it out. This works fine when used in the context I developed it (Use javascript to make an AJAX call to the URL and pass the order_id as a query parameter) I am now trying to reuse the exact same page in another application however I am calling it using php file_get_contents($base_url.'admin/send.email.php?order_id='.$order_id). When I call the page this way,

curl and file_get_contents both cannot find server by domain name set in hosts file

余生长醉 提交于 2019-12-11 06:13:35
问题 On both the PHP server and the client I have in /etc/hosts : 192.168.1.111 my-fake-domain-name.com The PHP server is that box (192.168.1.111). But when I use curl or file_get_contents to get anything from that alias ( my-fake-domain-name.com ) it always returns a 403 error. If I use the ip address, everything works fine. How do I get those programs to recognize the alias? //These do NOT work file_get_contents( "http://my-fake-domain-name.com" ); curl_setopt($ch, CURLOPT_URL, "http://my-fake

no return for file_get_contents()?

不打扰是莪最后的温柔 提交于 2019-12-11 06:13:04
问题 why i not getting return on file_get_contents($myurl) but i do get output for wget updated: i use curl to get the return header and result and discovery that the it is on the header instead in of the body HTTP/1.1 200 Document follows Transfer-Encoding: chunked Content-type: text/plain Server: XMS (724Solutions HTA XSAM_30_M2_B020 20070803.172831) Date: Fri, 21 May 2010 10:48:31 GMT Accept-Ranges: bytes HTTP/1.1 404 ChargedPartyNotAvailable Transfer-Encoding: chunked Content-type: text/plain