Skip to content

Commit

Permalink
Merge pull request #93 from jreklund/master
Browse files Browse the repository at this point in the history
New style for demo, updated readme and one bug
  • Loading branch information
tboothman authored Apr 17, 2017
2 parents 4dd9b04 + c762c6f commit 0dfeb7d
Show file tree
Hide file tree
Showing 8 changed files with 1,081 additions and 644 deletions.
46 changes: 32 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Install the files:

### Requirements
* PHP >= 5.3
* PHP Curl extension
* PHP cURL extension


Configuration
Expand All @@ -47,7 +47,7 @@ Configuration is done by the `\Imdb\Config` class in `src/Imdb/Config.php` which
You can alter the config by creating the object, modifying its properties then passing it to the constructor for imdb.
```php
$config = new \Imdb\Config();
$config->language = 'de-DE';
$config->language = 'de-DE,de,en';
$imdb = new \Imdb\Title(335266, $config);
$imdb->title(); // Lost in Translation - Zwischen den Welten
$imdb->orig_title(); // Lost in Translation
Expand All @@ -63,11 +63,11 @@ Searching for a film
```php
// include "bootstrap.php"; // Load the class in if you're not using an autoloader
$search = new \Imdb\TitleSearch(); // Optional $config parameter
$results = $search->search('The Matrix', [\Imdb\TitleSearch::MOVIE]); // Optional second parameter restricts types returned
$results = $search->search('The Matrix', array(\Imdb\TitleSearch::MOVIE)); // Optional second parameter restricts types returned

// $results is an array of Title objects
// The objects will have title, year and movietype available
// immediately, but any other data will have to be fetched from IMDb
// immediately, but any other data will have to be fetched from IMDb
foreach ($results as $result) { /* @var $result \Imdb\Title */
echo $result->title() . ' ( ' . $result->year() . ')';
}
Expand Down Expand Up @@ -100,14 +100,32 @@ Gotchas / Help
==============
SSL certificate problem: unable to get local issuer certificate
---------------------------------------------------------------
###Windows
The curl library either hasn't come bundled with the root SSL certificates or they're out of date. You'll need to set them up:
1. [Download cacert.pem](https://curl.haxx.se/docs/caextract.html)
2. Store it somewhere in your computer.
`C:\wamp64\bin\php\php7.0.10\extras\ssl\cacert.pem`
3. Open your php.ini and add the following under [curl]
`curl.cainfo = "C:\wamp64\bin\php\php7.0.10\extras\ssl\cacert.pem"`
4. Restart your webserver
###Linux
Curl uses the certificate authority file that's part of linux by default, which must be out of date.
### Windows
The cURL library either hasn't come bundled with the root SSL certificates or they're out of date. You'll need to set them up:
1. [Download cacert.pem](https://curl.haxx.se/docs/caextract.html)
2. Store it somewhere in your computer.
`C:\php\extras\ssl\cacert.pem`
3. Open your php.ini and add the following under `[curl]`
`curl.cainfo = "C:\php\extras\ssl\cacert.pem"`
4. Restart your webserver.
### Linux
cURL uses the certificate authority file that's part of linux by default, which must be out of date.
Look for instructions for your OS to update the CA file or update your distro.

Configure languages
---------------------------------------------------------------
Sometimes IMDb gets unsure that the specified language are correct, if you only specify your unique language and territory code (de-DE). In the example below, you can find that we have chosen to include `de-DE (German, Germany)`, `de (German)` and `en (English)`. If IMDb can’t find anything matching German, Germany, you will get German results instead or English if there are no German translation.
```php
$config = new \Imdb\Config();
$config->language = 'de-DE,de,en';
$imdb = new \Imdb\Title(335266, $config);
$imdb->title(); // Lost in Translation - Zwischen den Welten
$imdb->orig_title(); // Lost in Translation
```
Please use The Unicode Consortium [Langugage-Territory Information](http://www.unicode.org/cldr/charts/latest/supplemental/language_territory_information.html) database for finding your unique language and territory code.

| Langauge | Code | Territory | Code |
| -------- | ---- | ----------- | ---- |
| German | de | Germany {O} | DE |

After you have found your unique language and territory code you will need to combine them. Start with language code (de), add a separator (-) and at last your territory code (DE); `de-DE`. Now include your language code (de); `de-DE,de`. And the last step add English (en); `de-DE,de,en`.
20 changes: 11 additions & 9 deletions demo/cache.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

#############################################################################
# IMDBPHP (c) Giorgos Giagas & Itzchak Rehberg #
# written by Giorgos Giagas #
Expand All @@ -11,6 +10,7 @@
# ------------------------------------------------------------------------- #
# Show what we have in the Cache #
#############################################################################

require __DIR__ . "/../bootstrap.php";

use \Imdb\Title;
Expand All @@ -29,31 +29,33 @@
?>

<!DOCTYPE html>
<html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>IMDbPHP Cache Contents</title>
<style type='text/css'>body,td,th { font-size:12px; }</style>
<link rel="stylesheet" href="style.css">
</head>
<body>
<?php if (empty($movies)): ?>
Nothing in cache
<h2 class="text-center">Nothing in cache</h2>
<?php else: ?>
<table align="center" border="1" cellpadding="3" style="border-collapse:collapse;margin-top:20px;">
<h2 class="text-center">Cache Contents</h2>
<table class="table">
<tr>
<th style="background-color:#FFB000">Movie</th>
<th style="background-color:#FFB000">IMDb</th>
<th>Movie</th>
<th>IMDb</th>
</tr>

<?php foreach ($movies as $movie): ?>
<tr>
<td><?php echo $movie->title() ?></td>
<td align="center">
<td class="text-center">
<a href="movie.php?mid=<?php echo $movie->imdbid() ?>">Cache</a> |
<a href="<?php echo $movie->main_url() ?>">IMDb</a>
</td>
</tr>
<?php endforeach ?>
</table>
<?php endif ?>
<p class="text-center"><a href="index.html">Go back</a></p>
</body>
</html>
2 changes: 1 addition & 1 deletion demo/inc.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
function esc($str) {
return htmlspecialchars($str);
return htmlspecialchars($str,ENT_QUOTES,'UTF-8');
}
27 changes: 17 additions & 10 deletions demo/index.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<title>IMDbPHP movie search</title>
<style type="text/css">body,td,th { font-size:12px; font-family:sans-serif; }</style>
<meta charset="utf-8">
<title>IMDbPHP - Movie Search</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h2 class="text-center">Movie Search</h2>
<form action="search.php" method="get">
<table align="center" style="margin-top:20px;border-collapse:collapse;" border="1">
<tr><th colspan="2" style="background-color:#FFB000">IMDbPHP Movie Search</th></tr>
<table>
<tr><th colspan="2">IMDbPHP</th></tr>
<tr>
<td align="right" style="padding-right:10px;padding-left:10px;">Name:<br>Type:</td>
<td class="bb-none text-right pl-10 pr-10">Name:</td>
<td>
<input type="text" name="name" size="30" maxlength="50"><br>
</td>
</tr>
<tr>
<td class="text-right pl-10 pr-10">Type:</td>
<td>
<select name="searchtype">
<option value="movie">Movie</option>
<option value="episode">Episode</option>
Expand All @@ -20,12 +27,12 @@
</td>
</tr>
<tr>
<td align="right" style="padding-right:10px;padding-left:10px;">or IMDb ID:</td>
<td><input type="text" name="mid" size="30" maxlength="7"></td>
<td class="text-right pl-10 pr-10">or IMDb ID:</td>
<td><input type="text" name="mid" size="30" maxlength="9"></td>
</tr>
<tr><td colspan="2" align="center"><input type="submit" value="search"></td></tr>
<tr><td colspan="2" class="text-center"><input type="submit" value="search"></td></tr>
</table>
</form>
<p align="center"><a href="cache.php">View movies in cache</a></p>
<p class="text-center"><a href="cache.php">View movies in cache</a></p>
</body>
</html>
Loading

0 comments on commit 0dfeb7d

Please sign in to comment.