Ver Mensaje Individual
  #1 (permalink)  
Antiguo 07/06/2012, 10:23
mmchu
 
Fecha de Ingreso: mayo-2012
Mensajes: 15
Antigüedad: 12 años, 9 meses
Puntos: 0
Pregunta Warning: file_get_contents

Estoy utilizando facebook comments en mis posts y encontré el siguiente código para obtener por php la cantidad de comentarios:
Código PHP:
<?php
$query 
urlencode("select commentsbox_count from link_stat where url = 'http://techcrunch.com/2012/03/31/dramacrunch/'");
$response json_decode(file_get_contents("https://graph.facebook.com/fql?q=$query"), TRUE);
if(!empty(
$response['data'][0]['commentsbox_count'])) {
    echo 
$response['data'][0]['commentsbox_count'] . " comments were found!";
}
?>
Lo modifiqué ya que la url debería ser dinámica:
Código PHP:
<?php
$url 
urlencode(get_permalink($post->ID));
$query urlencode("select commentsbox_count from link_stat where url = '$url'");
$response json_decode(file_get_contents("https://graph.facebook.com/fql?q=$query"), TRUE);
echo 
$response['data'][0]['commentsbox_count'];
?>
Funciona aveces y otras veces me aparece una advertencia:

Warning: file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /www/patricioherrera.com.ar/htdocs/wp-content/themes/ph/index.php on line 50

Warning: file_get_contents(https://graph.facebook.com/fql?q=select+commentsbox_count+from+link_stat+wher e+url+%3D+%27http%253A%252F%252Fpatricioherrera.co m.ar%252Fwork-number-3%252F%27) [function.file-get-contents]: failed to open stream: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /www/patricioherrera.com.ar/htdocs/wp-content/themes/ph/index.php on line 50


La línea 50 es esta:
Código PHP:
$response json_decode(file_get_contents("https://graph.facebook.com/fql?q=$query"), TRUE); 
Cuál es el motivo?
Estoy cometiendo algún error al modificarlo?

Muchas gracias.