'ok', 'TestIfCookie' => 'ok', 'TestIfCookieP' => 'ok'); public $nb_pages_movies = 0; public function __construct($login, $password) { $data = array( 'refPartnerConnect' => '1', 'partnerKey' => '', 'login' => $login, 'password' => $password, ); $url = 'http://www.allocine.fr/community/json/connection.ashx'; list($headers, $body) = HTTP_query::query('POST', $url, $this->cookies, $data); $cookies =& $headers['_cookies']; if (empty($cookies['AClogin']) || $cookies['AClogin'] != $login) throw new Allocine_Exception("Invalid login"); $this->cookies = array_merge($this->cookies, $cookies); unset($headers, $body, $cookies, $data); } /** * Récupère la liste des films qu'on a noté et critiqué avec leur note, par page. * * La note -2 signifie "Je veux le voir", -1 "Pas intéressé" et de 0 à 4 la notation normale */ public function getFavoriteMovies($page=1) { $data = array( 'version' => '1.1', 'id' => time(), 'method' => 'GetFavoriteMovies', 'params' => array( 'param' => array( 'bookmark' => '', 'review' => '', 'rate' => '', 'alert' => '', 'fan' => '', 'order' => '', 'page' => $page, ), 'page' => $page, ), ); list(, $body) = HTTP_query::query('POST', 'http://www.allocine.fr/ws/community/UserFavoriteItemsHandler.ashx', $this->cookies, array('json' => $data)); $body = json_decode($body); if (empty($this->nb_pages_movies)) { $nb = count($body->result->value); $total = (int) $body->result->nbTotalItems; $this->nb_pages_movies = ceil($total / $nb); } $movies = array(); foreach ($body->result->value as $movie) { $movies[] = array( 'id' => $movie->Id, 'name' => $movie->Name, 'url' => 'http://www.allocine.fr/film/fichefilm_gen_cfilm='.$movie->Id.'.html', 'rating'=> $movie->Rating, 'review'=> $movie->reviewBody, 'poster'=> $movie->poster, ); } unset($body, $movie); return $movies; } } ?>