file-get-contents

Perl equivalent of PHP's get_file_contents() ?

The following PHP code does exactly what I want to do. The problem is I need to re-create it in Perl and I've been playing around with the open() and sysopen() Perl functions but can't do it. Does anyone have any help or know of any links that might help? Thanks. $URL = "http://example.com/api.php?arguments=values"; echo file_get_conten...

file_get_contents not working for local files

I recently upgraded my XAMPP from PHP 5.2 to 5.3.1 I seem to be having a problem with file_get_contents(). I can use the function to get something like "http://www.google.com", but it times out when I use it on a domain I have setup locally e.g. "http://localhost/my_dir/my_css_file.css". I'm not really sure what the problem is. If it'...

why does file_get_contents get nothing from the web service?

hi all, we're using file_get_contents to communicate with a web service, which creates users and if succeeds it returns a JSON object with the details of the new created user. the code below shows how we do it, the user is successfully created, meaning we can see it from the back-end, however, we just can't get the JSON response, it re...

How do I fetch the contents of a page no matter what HTTP status code?

I'm currently using file_get_contents() to fetch the contents of a page which is sort of like an Authentication API. It works great for the default system which most people use (which just uses the default HTTP/1.1 200 status code), but some people send relevant HTTP status codes for different errors. For example 401 PASSWORD_FAIL, in wh...

PHP ini file_get_contents external url

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...

PHP Retry Script until Success or Error

Hi there, Thank you for taking the time to read this and I will appreciate every single response no mater the quality of content. :) I'm trying to create a php script which retries another php script up to 3 times until an error message is displayed. I'm thinking perhaps this could be done using a php loop? If the code works successful...

How to download multiple files from URL in PHP?

I have this array. $urls = array( '0'=>'http://www.domain.com/media1.mp3' '1'=>'http://www.domain.com/media2.mp3' '2'=>'http://www.domain.com/media3.mp3' ) I wan to download these files simultaneously with the help of PHP. How do I do that? Any suggestions? I have tried putting headers in for loop but what it does is it combines the...

cURL Html output different from original page when rendered

Hi. I am working on a project that involves fetching pages with cURL or file_get_contents. The problem is that when i try to echo the html fetched, the output seem to be different from the original page, not all images show up. Please i would like to know if there is a solution. My code <?php //Get the url $url = "http://www...

file_get_contents is not finding a file that exists

I have a file that I'd like another script to access using file_get_contents The file I'd like it to access is in the directory above it, so I'm using file_get_contents('../file.php?this=that') However, it's returning No such file or directory and I can't understand why. The file is there. I'm assuming it has something to do with it b...

char limit with php file_get_contents() and Google Chart API?

Hi, the specific issue I am working on is enabling https with Google charts API, and a possible character limit when using php file_get_contents on a url string. Let me take you through what is going on. I have made good progress using some tutorials on the net, specifically to enable the https. I am using their 'basic method' from this ...

View the actual $string processed by file_get_contents($string) in php

I'm forced to use an older version of php on a server, and it seems to have a bug in the function file_get_contents(); I believe it's a bug because the issue doesn't happen on the current version of php. $string = 'intraneturl/?really_long_example_query_parameters'; When I pass the $string into file_get_contents($string); the part wit...

PHP file_get_contents ignoring timeout?

$url = 'http://a.url/i-know-is-down'; //ini_set('default_socket_timeout', 5); $ctx = stream_context_create(array( 'http' => array( 'timeout' => 5, 'ignore_errors' => true ) ) ); $start = microtime(true); $content = @file_get_contents($url, false, $ctx); $end = microtime(true); echo $end - $start, "\n"; ...

How to get remote page with php cURL securely

I will have an app where I will prompt users for a URL (with proper regex url validation) and return the page with cURL and run some checks on it. What would be the most secure way of returning a remote webpage securely with cURL? As I understand even cURL has some vulnerabilities, like 'safe mode' Security Bypass (http://www.securityfo...

file_get_contents get file from string not working

File I'm trying to save is from this url; http://m.assetbar.com/achewood/autaux?b=M%5ea11f09b8576e606bcb5038dfdb92fb821&amp;u=http%3A%2F%2Fachewood.com%2Fcomic.php%3Fdate%3D09102010 This does not work (only with this url): file_get_contents($string) But this works just fine: file_get_contents('http://m.assetbar.com/achewood/autaux?b=M...

PHP Get Content of HTTP 400 Response

I am using PHP with the Amazon Payments web service. I'm having problems with some of my requests. Amazon is returning an error as it should, however the way it goes about it is giving me problems. Amazon returns XML data with a message about the error, but it also throws an HTTP 400 (or even 404 sometimes). This makes file_get_contents...

Is PHP timing out, or is it something else that's causing my script's results to vary after each execution?

I have a directory full of XML files. For each of these files I make a search at RIPE. For each search I do a couple of RegEx searches through the returned HTML code. But after a couple of loops, file_get_contents stop returning data, and all my operations after are done on an empty string. I figured PHP may be timing out since these pa...

how to obtain the second page with file_get_contents

The idea is to get all the page with file_get_contents for a history record. When I do $original_file_div = file_get_contents("http://webpage.com/"); I have a webpage that ask for an email If I enter to the webpage with any browser I see that page, but ... when I press refresh I have access to a new page. I tried to do: $original...

How to download php generated zip/rar file with file_get_contents

I have small issue with php file_get_contents(); i try to download compressed packages from url like "http://mydomain.com?download.php?id=1234" downloading same file with browser works and all headers seems to be ok but through file_get_contents file is empty... ...

Is there anyway to make simpleXML work on web host.

<?php $twitter_url = 'http://twitter.com/statuses/user_timeline/ishrikrishna.xml?count=1'; $buffer = file_get_contents($twitter_url); $xml = new SimpleXMLElement($buffer); $status = $xml -> status; $tweet = $status -> text; echo $tweet; ?> I used this code to fetch tweets and it works successfully on localhost but not on my ...

Checking for site reciprocal link

I'm trying to make a script that will load a desired URL (as entered by user) and check if that page links back to my domain before their domain is published on my site. I'm not very experienced with regular expressions and this is what I have so far: $loaded = file_get_contents('http://localhost/small_script/page.php'); // $loaded will...