error when use file_get_contents on gae for php

453 views
Skip to first unread message

Chun-Ta Kung

unread,
Jun 19, 2013, 2:07:15 AM6/19/13
to google-a...@googlegroups.com
Hi,

I tested the sample code on this page: https://developers.google.com/appengine/docs/php/urlfetch/ 

the script is like this:

$data = array('data' => 'this', 'data2' => 'that');
$data = http_build_query($data);
$context =
    array("http"=>
      array(
        "method" => "get",
        "header" => "custom-header: custom-value\r\n" .
                    "custom-header-two: custome-value-2\r\n" ,
        "content" => $data
      )
    );
$context = stream_context_create($context);
$result = file_get_contents("http://app.com/path?query=update", false, $context);


However, I always get an error from server like below:

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 14

Warning: file_get_contents(http://app.com/path?query=update): 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 14





Even I use the simplest code, I will get the same error.
<?php 
file_get_contents('http://www.google.com');
?>

Any idea?

Amy Unruh

unread,
Jun 19, 2013, 8:53:49 PM6/19/13
to google-a...@googlegroups.com
It sounds like your computer might be having trouble resolving hostnames-- have you noticed any other indications of that?


--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengi...@googlegroups.com.
To post to this group, send email to google-a...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Vinny P

unread,
Jun 20, 2013, 5:23:26 PM6/20/13
to google-a...@googlegroups.com
On Wed, Jun 19, 2013 at 1:07 AM, Chun-Ta Kung <chunt...@gmail.com> wrote:
Even I use the simplest code, I will get the same error.
<?php 
file_get_contents('http://www.google.com');
?>

Any idea?

 

Hello Chun-Ta,
 
+1 on Amy's suggestion, that your local computer is most likely having difficulties with DNS resolving.
 
You can double check if this is the problem by trying to send http requests directly to IP addresses. For example, instead of attempting to access http://google.com, try accessing http://74.125.227.192 (this IP address is listed as one of the A records for google.com, you can double check this by looking up the DNS information for Google).
 
If the direct query to the IP address works, then your computer is failing to resolve DNS properly. If this still fails, you may have a more complex issue.
 
-----------------
-Vinny P
Technology & Media Advisor
Chicago, IL

App Engine Code Samples: http://www.learntogoogleit.com
 
 
On Wed, Jun 19, 2013 at 7:53 PM, Amy Unruh <am...@google.com> wrote:
It sounds like your computer might be having trouble resolving hostnames-- have you noticed any other indications of that?
On 19 June 2013 16:07, Chun-Ta Kung <chunt...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages