I'm trying to use theMovieDB API for my website, it uses user inputted information such as IMDB ID, however I'm not sure how to get it to print the results, i can only get iframe working.
I'm new to API's and printing results etc so any help or information on usage would be great.
this is what my current code is for the iframe:
<iframe src="https://api.themoviedb.org/3/movie/{$video->imdb_id}?api_key=[API_KEY]&language=en-US" frameborder="0"></iframe>
Iv'e tried the pre-made code it generates on their site, such as the JQuery one and the three different PHP options however they don't print anything.
Thanks for any help :)
Here's the JQuery the site generated for me.
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.themoviedb.org/3/movie/tt6513656?language=en-US&api_key=[API_KEY]",
"method": "GET",
"headers": {},
"data": "{}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
The cURL it generated.
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.themoviedb.org/3/movie/tt6513656?language=en-US&api_key=[API_KEY]",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_POSTFIELDS => "{}",
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
cURL output.
"https://api.themoviedb.org/3/movie/tt6513656?language=en-US&api_key=[API_KEY]", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_POSTFIELDS => "{}", )); = curl_exec(); = curl_error(); curl_close(); if () { echo "cURL Error #:" . ; } else { echo ; } ?>