コード例 #1
0
ファイル: search_person.php プロジェクト: jephmann/apilab
$objPage = new Page();
$objPage->data = "http://docs.themoviedb.apiary.io/#";
$objPage->path = "../";
$objPage->subtitle = "Search Person";
$objPage->title = "TheMovieDB";
/*
 * 1. get the number of pages ("total_pages") from the query (retrieved via class method)
 * 2. use this number to get the results ("results") from each page
 * 3. push each results array into the larger data array
 * 4. compare the number of results arrays pushed with the number of results ("total_results") from the query (retrieved via class method)
 * 5. list key parameters from each result     * 
 */
$search_topic = "person";
$search_text = "John  Smith";
// test default; otherwise via input
$objMovieDB = new API_TheMovieDB();
$totals = $objMovieDB->totals($search_topic, $search_text);
$total_pages = $totals['total_pages'];
$total_results = $totals['total_results'];
$data_results = array();
for ($i = 1; $i <= $total_pages; $i++) {
    $url_search = $objMovieDB->url_search($search_topic, $search_text, $i);
    $page_data = $objMovieDB->retrieve_data($url_search, TRUE);
    $count_results = count($page_data['results']);
    for ($r = 0; $r < $count_results; $r++) {
        array_push($data_results, $page_data['results'][$r]);
    }
}
if ($total_results == count($data_results)) {
    $data = $data_results;
} else {
コード例 #2
0
ファイル: found_person.php プロジェクト: jephmann/apilab
$objPage->data = "http://docs.themoviedb.apiary.io/#";
$objPage->path = "../";
$objPage->subtitle = "Found Person";
$objPage->title = "TheMovieDB";
$topic = 'person';
if (isset($_GET['id'])) {
    $id = htmlspecialchars($_GET['id']);
    // via this url
} else {
    $id = 8635;
    // default for testing (Buster Keaton)
    $id = 101472;
    // default for testing (Buster Keaton)
}
$data = array($topic => array(), 'credits' => array(), 'images' => array());
$objMovieDB = new API_TheMovieDB();
// 1 of 3: topic data
$url_topic = $objMovieDB->url_found($id, $topic);
$data[$topic] = $objMovieDB->retrieve_data($url_topic, TRUE);
// topic
$person = $data[$topic];
$person_imdb = $person['imdb_id'];
$person_name = $person['name'];
$person_biography = $person['biography'];
$person_birthday = $person['birthday'];
$person_deathday = $person['deathday'];
$imdb_link = $objMovieDB->url_imdb_person($person_imdb);
// 2 of 3: topic's credits
$url_credits = $objMovieDB->url_found($id, $topic, 'movie_credits');
$data['credits'] = $objMovieDB->retrieve_data($url_credits, TRUE);
// credits
コード例 #3
0
ファイル: found_movie.php プロジェクト: jephmann/apilab
require_once '../_inc/first.php';
$objPage = new Page();
$objPage->data = "http://docs.themoviedb.apiary.io/#";
$objPage->path = "../";
$objPage->subtitle = "Found Movie";
$objPage->title = "TheMovieDB";
$topic = 'movie';
if (isset($_GET['id'])) {
    $id = htmlspecialchars($_GET['id']);
    // via this url
} else {
    $id = 11235;
    // default for testing (Local Hero)
}
$data = array($topic => array(), 'credits' => array(), 'images' => array());
$objMovieDB = new API_TheMovieDB();
// 1 of 3: topic data
$url_topic = $objMovieDB->url_found($id, $topic);
$data[$topic] = $objMovieDB->retrieve_data($url_topic, TRUE);
// topic
$movie = $data[$topic];
$movie_imdb = $movie['imdb_id'];
$movie_title = $movie['title'];
$movie_overview = $movie['overview'];
$movie_release_date = $movie['release_date'];
$imdb_link = $objMovieDB->url_imdb_movie($movie_imdb);
// 2 of 3: topic's credits
$url_credits = $objMovieDB->url_found($id, $topic, 'credits');
$data['credits'] = $objMovieDB->retrieve_data($url_credits, TRUE);
// credits
$credits = $data['credits'];