Пример #1
0
 * 
 * $movieInfo should contain all the details of that movie in associative Array Format
 * 
 * You can also grab based on a search string like:
 * $movieInfo  = $imdbObj->get('The Matrix');
 * 
 * For Full Details, refer to:
 * http://www.itsalif.info/content/imdb-details-grabber-using-php-dom-xpath-extract-movie-details
 */
include 'class.imdb.php';
// only showing error, i.e turning off warning as new imdb layout throws bunch of warnings
error_reporting(E_ERROR);
$imdbObj = new Imdb();
// a helper function to echo movie details
function echoMovieDetails(&$movieInfo)
{
    if ($movieInfo != false) {
        echo '<pre>';
        print_r($movieInfo);
        echo '</pre>';
    } else {
        echo '<pre>Invalid Search Term or Invalid Imdb URL. No such Movie exists on IMDB</pre>';
    }
}
$path = 'http://www.imdb.com/title/tt0133093/';
// the Matrix Movie
$matrixInfo = $imdbObj->get($path);
echoMovieDetails($matrixInfo);
$Title = 'The Italian Job (1969)';
$IMDB = $imdbObj->showCast(true)->get($Title);
echoMovieDetails($IMDB);
Пример #2
0
</p>
<p>
	<input type="text" name="movie" value="" size="35"/>
</p>
<p>
	<input type="submit" name="submit" value="Grab" /> &nbsp;
	<input type="reset" name="reset" value="Reset" />
</p>
</form>

<div class="movieInfo">
<?php 
include 'class.imdb.php';
$imdb = new Imdb();
if (isset($_POST['movie'])) {
    $movieInfo = $imdb->showCast(true)->get(trim($_POST['movie']));
    if ($movieInfo == false) {
        $movieInfo = array('error' => 'Invalid Search Term or URL');
    } else {
        foreach ($movieInfo as $k => $v) {
            $k = ucfirst($k);
            if ($k != 'Cast:') {
                echo <<<_INFO_
<p>
<h3><b>{$k}</b></h3>
{$v}
</p>
_INFO_;
            } else {
                echo '
<p>