1

I'm using Cakephp 2.6.1 and I would like to use an extern api. For this, I must request an url like that:

$json = file_get_contents($url);
$data = json_decode($json);

I try with file_get_contents, curl and HttpSocket. And i have that error:

php_network_getaddresses: getaddrinfo failed: Name or service not known

I check php_info(); and allow_url_fopen is On.

Thank you in advance to any one who may be able to give me some ideas.

Bechilled
  • 71
  • 7
  • 2
    And none of the [**Google search results**](https://www.google.com/search?q="php_network_getaddresses%3A+getaddrinfo+failed%3A+Name+or+service+not+known") helps in any way? – ndm Feb 12 '15 at 15:59
  • it's easier to look for a little as submitting a post... The problem seems to come from allow_url_fopen is off but not for me :/ i don't understand. – Bechilled Feb 12 '15 at 16:26
  • Are you on a server or local machine? – Eoin Murphy Feb 12 '15 at 16:41
  • I'm on a server. The code don't works anymore outside the php framework... Edit: It's look like a DNS problem. Somebody help me to fix it ? – Bechilled Feb 12 '15 at 18:27

2 Answers2

1

In my case

php_network_getaddresses: getaddrinfo failed: Name or service not known

it appears because my dsn address was no longer valid. I just replaced by valid adress dns and it works :)

Bechilled
  • 71
  • 7
0

You have to set up curl in your server

Follow this link

How to enable curl in Wamp server

Community
  • 1
  • 1
Smruti
  • 452
  • 4
  • 6