-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearchData.php
More file actions
36 lines (23 loc) · 783 Bytes
/
searchData.php
File metadata and controls
36 lines (23 loc) · 783 Bytes
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
<?php
$key = 'b02cc9599b562a85e12cabc7814de340';
function getSearchResult($key, $title, $page, $year, $adult)
{
$url = 'https://api.themoviedb.org/3/search/movie?api_key='.$key.'&language=en-US&query='.$title.'&page='.$page.'&include_adult='.$adult.'&year='.$year;
$content = file_get_contents($url);
$json = json_decode($content);
return $json;
}
function get_http_response_code($url) {
$headers = get_headers($url);
return substr($headers[0], 9, 3);
}
function getSearchDetail($key, $id)
{
$url = 'https://api.themoviedb.org/3/movie/'.$id.'?api_key='.$key.'&language=en-US&append_to_response=credits';
if(get_http_response_code($url) == "404")
return false;
$content = file_get_contents($url, true);
$json = json_decode($content);
return $json;
}
?>