我使用的是Cakephp 2.6.1,我想使用一个extern api。为此,我必须请求一个类似的url:
$json = file_get_contents($url);
$data = json_decode($json);
我尝试使用file_get_contents、curl和HttpSocket。我有一个错误:
php_network_getaddresses: getaddrinfo failed: Name or service not known
我检查php_info();
and allow_url_fopen
是否打开。
提前感谢任何能给我一些想法的人。
在我的情况下是
php_network_getaddresses: getaddrinfo failed: Name or service not known
它出现是因为我的dsn地址不再有效。我刚刚用有效的地址dns替换,它有效:)
您必须在服务器中设置curl
遵循此链接
如何在Wamp服务器中启用curl