Error en functions.php

  • Autor Autor kahlo
  • Fecha de inicio Fecha de inicio
kahlo

kahlo

Eta
Diseñador
Verificación en dos pasos activada
Verificado por Whatsapp
Hola, estoy intentando seguir este tutorial de WordPress para mostrar algunas imágenes de Instagram en un blog: Tutorial WP paso a paso: crear un widget con tus últimas fotos de Instagram, con cache y sin plugins | HacheMuda

Pero a la hora de copiar el código del paso 3, me da error y me deja el blog y el admin con una pantalla totalmente en blanco. Hay algún error en el código? Lo copio aquí para mayor comodidad:

PHP:
/****** GET THE LAST INSTAGRAM PHOTOS WITH CACHE *******/
/*
Replace "XXXXX" with the Instagram user ID and "ZZZZZ" with the Instagram Dev-App access token
*/
function get_user_instagram_photos($user_id=XXXXX, $count=6, $width=180, $height=180){
    $result = get_transient('last_instagrams');
   if ($result == false){
       $url = 'https://api.instagram.com/v1/users/'.$user_id.'/media/recent/?access_token=ZZZZZ&count='.$count;
      $jsonData = json_decode((file_get_contents($url)));
     $result = '';
       foreach ($jsonData->data as $key=>$value) {
           $result .= '\t'.'<a title="'.htmlentities($value->caption->text).' ('.htmlentities(date("d/m/Y", $value->caption->created_time)).')" href="'.$value->images->standard_resolution->url.'">';
           $result .= '<img src="'.$value->images->low_resolution->url.'" alt="'.$value->caption->text.'" width="'.$width.'" height="'.$height.'" />';
          $result .= '</a>';
        }
     set_transient('last_instagrams', $result, 60*60*24);
        update_option('last_instagrams', $result);    
    }
 return $result;
}

Saludos.
 
Hola, estoy intentando seguir este tutorial de WordPress para mostrar algunas imágenes de Instagram en un blog: Tutorial WP paso a paso: crear un widget con tus últimas fotos de Instagram, con cache y sin plugins | HacheMuda

Pero a la hora de copiar el código del paso 3, me da error y me deja el blog y el admin con una pantalla totalmente en blanco. Hay algún error en el código? Lo copio aquí para mayor comodidad:

PHP:
/****** GET THE LAST INSTAGRAM PHOTOS WITH CACHE *******/
/*
Replace "XXXXX" with the Instagram user ID and "ZZZZZ" with the Instagram Dev-App access token
*/
function get_user_instagram_photos($user_id=XXXXX, $count=6, $width=180, $height=180){
    $result = get_transient('last_instagrams');
   if ($result == false){
       $url = 'https://api.instagram.com/v1/users/'.$user_id.'/media/recent/?access_token=ZZZZZ&count='.$count;
      $jsonData = json_decode((file_get_contents($url)));
     $result = '';
       foreach ($jsonData->data as $key=>$value) {
           $result .= '\t'.'<a title="'.htmlentities($value->caption->text).' ('.htmlentities(date("d/m/Y", $value->caption->created_time)).')" href="'.$value->images->standard_resolution->url.'">';
           $result .= '<img src="'.$value->images->low_resolution->url.'" alt="'.$value->caption->text.'" width="'.$width.'" height="'.$height.'" />';
          $result .= '</a>';
        }
     set_transient('last_instagrams', $result, 60*60*24);
        update_option('last_instagrams', $result);    
    }
 return $result;
}

Saludos.
sin poner el error te digo que a simple vista puede ser esto...
Replace "XXXXX" with the Instagram user ID and "ZZZZZ" with the Instagram Dev-App access token

te dice que cambias las XXX por tu user y las ZZZ por el access token de programador en instagram...
 
Gracias, pero si eso ya lo cambié, sólo he copiado el original de la web para no poner mis datos :witless:
 
Claro esta en el comentario bro ^^
1º Replace "XXXXX" with the Instagram user ID
2º Replace "ZZZZZ" with the Instagram Dev-App access token


PHP:
/*
Replace "XXXXX" with the Instagram user ID and "ZZZZZ" with the Instagram Dev-App access token
*/
function get_user_instagram_photos($user_id=Instagram user ID, $count=6, $width=180, $height=180){
    $result = get_transient('last_instagrams');
   if ($result == false){
       $url = 'https://api.instagram.com/v1/users/'.$user_id.'/media/recent/?access_token=(Instagram Dev-App access token)&count='.$count;
      $jsonData = json_decode((file_get_contents($url)));
     $result = '';
       foreach ($jsonData->data as $key=>$value) {
           $result .= '\t'.'<a title="'.htmlentities($value->caption->text).' ('.htmlentities(date("d/m/Y", $value->caption->created_time)).')" href="'.$value->images->standard_resolution->url.'">';
           $result .= '<img src="'.$value->images->low_resolution->url.'" alt="'.$value->caption->text.'" width="'.$width.'" height="'.$height.'" />';
          $result .= '</a>';
        }
     set_transient('last_instagrams', $result, 60*60*24);
        update_option('last_instagrams', $result);    
    }
 return $result;
}
 
habilita el modo debug de wordpress para que te diga el error exacto.
 
Atrás
Arriba