-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontroleur_detail.php
80 lines (59 loc) · 1.9 KB
/
controleur_detail.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
if(isset($_GET['title']))
{
require_once('allocine-api/PHP/allocine.class.php');
define('ALLOCINE_PARTNER_KEY', '100043982026');
define('ALLOCINE_SECRET_KEY', '29d185d98c984a359e6e6f26a0474269');
$allocine = new Allocine(ALLOCINE_PARTNER_KEY, ALLOCINE_SECRET_KEY);
$result = $allocine->search(strval($_GET['title']));
$urls = explode(" ", $_GET['urls']);
$qualities = explode(" ", $_GET['qualities']);
$result = json_decode($result,true);
//echo " Resultats : ".$result['feed']['results'][0]['$'];
$code = 0;
if($result['feed']['results'][0]['$'] > 0)
{
foreach($result['feed']['movie'] as $movie)
{
if(isset($movie['originalTitle']) && $movie['originalTitle'] == $_GET['title'])
{
$code = $movie['code'];
break;
}
if($movie['productionYear'] == $_GET['year'])
{
$code = $movie['code'];
break;
}
}
}
if($code > 0)
{
$result = $allocine->get($code);
$result = json_decode($result,true);
$title = $_GET['title'];
$year = $_GET['year'] ;
//echo $result;
//echo var_dump($result['movie']);
include('detail_allocine.php');
}
else
{
try
{
if(!@$xml=simplexml_load_file('https://yts.to/api/v2/movie_details.xml?movie_id='.$_GET['movie_id'].'&with_images=true'))//movie_id='.$_GET['movie_id'].'&with_images=true'
{
throw new Exception("L'API YIFY ne répond pas.");
}
if(empty($xml->data->title) ) throw new Exception('Flux invalide');
include('detail.php');
}
catch(Exception $e)
{
//include('erreur.php')
echo $e->getMessage() ;
}
}
}
else
echo "l'id du film n'est pas valide ";