private function _requestFinalTokens($authorization_code)
 {
     $api_url = $this->composeVariables('http://api.netflix.com/oauth/access_token', array('output' => 'json'));
     $this->request->makeRequest($api_url, array());
     $response = $this->request->getRawResponse();
     preg_match_all('/oauth_token":"(.*)","user_id.*oauth_token_secret":"(.*)"/', $response, $results);
     $oauth_token = $results[1][0];
     $oauth_token_secret = $results[2][0];
     $this->storage->addUserToken($oauth_token, $oauth_token_secret, 4);
     /*
     For some reason, the above user ID doesn't work most of the time..
     let's re-query and get the final netflix user_id ....
     */
     $Netflix = new NetflixAPI();
     $user_info = $Netflix->getCurrentUser();
     $netflix_userid = preg_replace('/.*users\\//', '', $user_info->resource->link->href);
     $this->storage->addUserToken($oauth_token, $oauth_token_secret, 4, $netflix_userid);
     // Rediect user
     header("Location: " . $this->configs->app_redirect);
     exit;
 }
예제 #2
0
<?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->getUsersInfo();
// $results is now an array containing the results
echo "<pre>";
print_r($results);
echo "</pre><br/>";
<?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 ']}}';
예제 #4
0
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;
    echo "This function will return a list of your information.<br />" . PHP_EOL;
}
// Displaying results?
if (count($results) > 0) {
    echo "<br/ >" . PHP_EOL . "<b>Results of call:</b> <br />" . PHP_EOL;
    echo '<pre>';
    print_r($results);
    echo '</pre>';
}
$page_content = ob_get_contents();
ob_end_clean();
?>
<p><strong>Netflix API 1.0 Demo [<a href="documentation.html" target="_blank">Documentation</a>]</strong></p>