0
votes

I am developing application on google app engine for php, I need to use file_get_contents to parse a website.

However, I met a problem from my server. For example, I run a single line of code like below:

<?php

    $html = file_get_contents('http://www.google.com');

?>

The server returns warnings and cannot execute what I plan to do.

Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: A non-recoverable error occurred during a database lookup. in C:\gae_work\helloworld\helloworld.php on line 3

Warning: file_get_contents(http://www.google.com): failed to open stream: php_network_getaddresses: getaddrinfo failed: A non-recoverable error occurred during a database lookup. in C:\gae_work\helloworld\helloworld.php on line 3

Any similar experience? Please!

2
It seems to be a DNS/firewall setting problem on your local machine. Are you still getting the same error with the latest SDK?Mars

2 Answers

1
votes

Form Google App Engine Docs

URL Fetch and the Development Server

When your application is running in the development server on your computer, calls to the URL Fetch service are handled locally. The development server fetches URLs by contacting remote hosts directly from your computer, using whatever network configuration your computer is using to access the Internet.

When testing the features of your app that fetch URLs, be sure that your computer can access the remote hosts.

If your app is using the Google Secure Data Connector to access URLs on your intranet, be sure to test your app while connected to your intranet behind the firewall. Unlike App Engine, the development server does not use the SDC Agent to resolve intranet URLs. Only Google Apps and App Engine can authenticate with your SDC Agent.

More : https://developers.google.com/appengine/docs/php/urlfetch/

I think you need to check allow_url_fopen is open or not in your installation.

0
votes

If you only want to submit GET data to the URL, you should use something straightforward like

file_get_contents();

$myGetData = "?param1=param_val1&param2=param_val2";
file_get_contents($url.$myGetData);