I started getting these warnings just recently, im not sure why, nor do i know how to fix it. What confuses me more, it was working before, i started working on another class and now i starting getting this error…
im using linux fedora & apache for the webserver.
Warning: simplexml_load_file()
[function.simplexml-load-file]:
php_network_getaddresses: getaddrinfo
failed: Name or service not known in
GetImagesFlickr.php
on line 17Warning:
simplexml_load_file(http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=9eb9f5e5fb72d6d2fed06cf4e64ba9bb&media=photos&per_page=50&text=fgdc)
[function.simplexml-load-file]: failed
to open stream:
php_network_getaddresses: getaddrinfo
failed: Name or service not known in
GetImagesFlickr.php
on line 17Warning: simplexml_load_file()
[function.simplexml-load-file]: I/O
warning : failed to load external
entity
“http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=9eb9f5e5fb72d6d2fed06cf4e64ba9bb&media=photos&per_page=50&text=fgdc”
in
/var/www/html/yahoo/GetImagesFlickr.php
on line 17
<?php
class GetImagesFlickr
{
const API_KEY = "***"; // Flickr api key
const MAX_RESULTS_RETURNED = 50; // Max results returned in search
private $url; // Flickr webservice url
public function __construct ()
{
$this->url = "http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=".self::API_KEY."&media=photos&per_page=".self::MAX_RESULTS_RETURNED;
}
public function getImages ($search_term)
{
// Perform search and store xml data
$xml_data = simplexml_load_file("{$this->url}&text={$search_term}");
$search_results = array();
// Go through xml data and store to array
foreach ($xml_data->photos->photo as $current_photo)
{
$id = $current_photo['id'];
$title = $current_photo['title'];
$farm = $current_photo['farm'];
$secret = $current_photo['secret'];
$server = $current_photo['server'];
$url = "http://farm{$farm}.static.flickr.com/{$server}/{$id}_{$secret}.jpg";
$complete_photo = array (
'id' => $id,
'title' => $title,
'farm' => $farm,
'secret' => $secret,
'server' => $server,
'url' => $url
);
$search_results[] = $complete_photo;
}
return $search_results;
}
}
?>
You have a network/DNS problem, not a PHP problem. Seems your machine cannot resolve the IP of
api.flickr.com.“su” to your web server user and try to resolve the name there, i.e.