i'm trying to make a imdb ratingchecker on my website. i've come that far so i can use parts of the URL to chack the rating and print it on my page using cURL+php+ajax/jQuery. but it just needs the last part of the imdb-link to function correctly and use omdbapi.com's function to rip out the rating.
but if the user inputs http://www.imdb.com/title/tt2268016/ it will not work. but if the user inputs only tt2268016 the function work like a charm. so my problem is that i don't realy know how to either remove http://www.imdb.com/title/ and leave the tt2268016 by and use that.
the code that's doing the url handling is this:
if (empty($_POST['imdbnum'])){
$imdb = 'none';
$imdblink = 'none';
}else{
$imdb = unesc($_POST['imdbnum']);
function get_movie_ratings($name)
{
$url = "https://omdbapi.com/?i=".urlencode($name);
// send request
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$curlData = curl_exec($curl);
curl_close($curl);
return json_decode($curlData, true);
}
$imdb2 = get_movie_ratings($imdb);
$imdbrate = $imdb2["imdbRating"];
$imdblink = unesc($_POST['imdbnum']);
}
how do i solve this in a smooth way?
Best Regards!