This repository has been archived by the owner on Feb 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
moviemeter.php
82 lines (71 loc) · 1.62 KB
/
moviemeter.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
81
82
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
require("lib/xmlrpc.inc");
require("lib/xmlrpcs.inc");
require("lib/xmlrpc_wrappers.inc");
// CHANGE THIS API KEY TO YOUR OWN
$api_key = '1234567890';
$imdbid = (isset($_GET['imdbid']) ? $_GET['imdbid'] : '');
if ($imdbid)
{
// start client
$client = new xmlrpc_client("http://www.moviemeter.nl/ws");
$client->return_type = 'phpvals';
/*
*start session and retrieve sessionkey
*/
$message = new xmlrpcmsg("api.startSession", array(new xmlrpcval($api_key, "string")));
$resp = $client->send($message);
if ($resp->faultCode())
{
die('error: '. $resp->faultString());
}
else
{
$session_info = $resp->value();
$session_key = $session_info['session_key'];
}
/*
* search for movie
*/
$message = new xmlrpcmsg("film.retrieveByImdb", array(new xmlrpcval($session_key, "string"), new xmlrpcval($imdbid, "string")));
$resp = $client->send($message);
if ($resp->faultCode())
{
die('error: '. $resp->faultString());
}
else
{
$results = $resp->value();
$message = new xmlrpcmsg("film.retrieveDetails", array(new xmlrpcval($session_key, "string"), new xmlrpcval($results, "int")));
$resp = $client->send($message);
if ($resp->faultCode())
{
die('error: '. $resp->faultString());
}
else
{
$results = $resp->value();
echo $results['plot'];
}
}
$message = new xmlrpcmsg("api.closeSession", array(new xmlrpcval($session_key, "string")));
$resp = $client->send($message);
if ($resp->faultCode())
{
die('error: '. $resp->faultString());
}
else
{
$results = $resp->value();
}
if (isset($results))
{
exit();
}
}
else
{
exit;
}