开发者

file_get_contents failing

I have a blog on tumblr, and I'm trying to access it via php and tumblrs api.

the api endpoint is:

http://blog.example.com/api/read/json?start=0&num=10&debug=1

and that seems to work fine.

However, when I do:

$result = file_get_contents("http://blog.example.com/api/read/json?start=0&num=10&debug=1");

print_r($result);

the browser outputs

Warning:  file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /path/to/file/test.php on line 5

Warning:  file_get_contents(http://blog.example.com/api/read/json?start=0&num=10&debug=1) [function.file-get-contents]: failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not 开发者_如何学JAVAknown in /path/to/file/test.php on line 5

This also fails with Curl.

Ideas?

I think this has something to do with the fact that my blog is on a subdomain. The reason I say this, is, if I run the same script on a blog located on the root url, it works fine. Is there a correct way to escape subdomains?


This code is failing because the DNS lookup is failing. This could be because your server is having trouble contacting its name servers. Or its because blog.example.com doesn't exist (it fails in my browser so it should fail everywhere). You could try changing your name servers to google's: 8.8.8.8 and 8.8.4.4. These DNS servers work well.


New Tumblr API: http://www.tumblr.com/docs/en/api/v2

If you have your domain with your tumblr account it will work. An example

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜