<?php

define('BASE_DIR', dirname(__FILE__) . '/');
require_once BASE_DIR . 'Configuration.php';
require_once BASE_DIR . 'includes/NetflixAPI.php';
require_once BASE_DIR . 'includes/Request.php';
require_once BASE_DIR . 'includes/OAuthSimple.php';
require_once BASE_DIR . 'netflix/nonAuthenticatedCall.php';
require_once BASE_DIR . 'netflix/protectedCall.php';
require_once BASE_DIR . 'netflix/signedCall.php';
require_once BASE_DIR . 'netflix/getToken.php';
$query = !empty($_REQUEST['q']) ? $_REQUEST['q'] : 'Rocky';
$Netflix = new NetflixAPI();
$results = $Netflix->getCatalogTitlesAutoComplete($query);
//$results is now an array containing the results
//DEBUG: echo "<pre>"; print_r($results); echo "</pre><br/>";
echo '{ "movie": { "title": [';
foreach ($results->autocomplete->autocomplete_item as $movie) {
    echo '"' . $movie->title->short . '", ';
}
echo ']}}';
Exemplo n.º 2
0
require_once BASE_DIR . 'includes/OAuthSimple.php';
require_once BASE_DIR . 'netflix/nonAuthenticatedCall.php';
require_once BASE_DIR . 'netflix/protectedCall.php';
require_once BASE_DIR . 'netflix/signedCall.php';
require_once BASE_DIR . 'netflix/getToken.php';
// Check if we are doing any demos
$results = array();
// Check demo variable
if (!isset($_GET['demo'])) {
    $_GET['demo'] = '';
}
ob_start();
// Non authenticated call
if ($_GET['demo'] == 1) {
    $netFlixApi = new NetflixAPI();
    $results = $netFlixApi->getCatalogTitlesAutoComplete('America');
    echo "<hr />We just made the function call getCatalogTitlesAutoComplete with America as a parameter.<br />" . PHP_EOL;
    echo "This function calls the auto complete API resource.<br />" . PHP_EOL;
}
// Non authenticated call
if ($_GET['demo'] == 2) {
    $netFlixApi = new NetflixAPI();
    $results = $netFlixApi->getCatalogTitles('America');
    echo "<hr />We just made the function call getCatalogTitles with America as a parameter.<br />" . PHP_EOL;
    echo "This function calls the get catalog title API resource.<br />" . PHP_EOL;
}
// Non authenticated call
if ($_GET['demo'] == 3) {
    $netFlixApi = new NetflixAPI();
    $results = $netFlixApi->getUsersInfo();
    echo "<hr />We just made the function call getUsersInfo.<br />" . PHP_EOL;