Ver Mensaje Individual
  #1 (permalink)  
Antiguo 31/12/2011, 06:30
MadDunDee
 
Fecha de Ingreso: octubre-2006
Mensajes: 199
Antigüedad: 20 años
Puntos: 3
Recuperar datos API

Hola,

estoy tratando de realizar un espacio basado en dribbble y necesito acceder a la API del servicio. Para ello estoy utilizando este método:

Código PHP:
<?php

 error_reporting
(E_ALL); 
 
ini_set("display_errors", 1); 

require_once(
'../src/dribbble.php');

$dribbble = new Dribbble();


?>
Primero accedo a la clase que podéis ver aquí

A partir de ahí necesito acceder a la lista de shots de un usuario en concreto y además a una lista de shots destacados (esto está por montar también todavía). Para el primer punto funciona bien así: (recuperar shots)

Código PHP:
<?php
                                                    
                        
try {
                            
$my_shots = $dribbble->get_player_shots('username');
                            foreach (
$my_shots->shots as $shot) {
                                echo 
'<li><h3><a href="'. $shot->url .'">' . $shot->title . '</a></h3><a class="in-shot" href="' . $shot->url . '"><img src="'. $shot->image_url .'" alt="' . $shot->title . '"><p id="date-shot">Posted: ' . $shot->created_at . '</p></a></li>';
                            }
                        }
                        catch (
DribbbleException $e) {
                            echo 
'Error: ' . $e->getMessage();
                        } 
?>
Con esto me devuelve los shots de un player. Pero cuando trato de hacer lo mismo con los datos del player me aparece este error:

NOTICE: UNDEFINED PROPERTY: STDCLASS::$PROPS IN[...]
WARNING: INVALID ARGUMENT SUPPLIED FOR FOREACH() IN [...]


El método que utilizo es el mismo que para los shots:

Código PHP:
<?php 
            
try {
               
$vars = $dribbble->get_player('username'); 
                foreach (
$vars->props as $values) {
                echo 
'<li><h3><a href="'. $values->url .'">' . $values->name . '</a></h3><a class="in-shot" href="' . $values->url . '"><img src="'. $values->avatar_url .'" alt="' . $values->title . '"><p id="date-shot">Posted: ' . $values->created_at . '</p></a></li>';
                       }
               }
                catch (
DribbbleException $e) {
                echo 
'Error: ' . $e->getMessage();
               }
                        
            
?>
Supongo que no estoy accediendo correctamente al array y se trata de un problema de sintaxis. Me podríais echar una mano?

Aquí tenéis la API de DRIBBBLE -> http://dribbble.com/api

Espero que me podáis ayudar, muchas gracias!