The Movie Database support

it seems like the Json Dataset $data is retrieved, however, it cannot be parsed correctly. Can someone help?

Thanks in advance!

if (extension_loaded('curl'))
{
    $headers = array(
        'Accept: application/json',
    );
    $apikey = '###';
    $query = ('Iron+Man+1');
    $url = 'https://api.themoviedb.org/3/search/movie?api_key' . $apikey . '&query=' . $query;


    $session = curl_init();
    curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($session, CURLOPT_URL,$url);
    curl_setopt($session, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($session, CURLOPT_HEADER, 1);
    $data = curl_exec($session);
    if ($data === NULL) die ('result sets are empty');


    $header_size = curl_getinfo($session, CURLINFO_HEADER_SIZE);
    $header = substr($data, 0, $header_size);
    $body = substr($data, $header_size);

    $error_number = curl_errno($session);
    $error_message = curl_error($session);

    curl_close($session);
}
else
{
    throw new TMDbException('CURL-extension not loaded');
}

$results = json_decode($body, true);
if ($results === NULL) die('Error parsing json');
$moviesRelease = $results➞release_date;

3 svar (på side 1 af 1)

Jump to last post

Hi vanessaLing,

First, this is PHP right? It might be helpful to add PHP to the subject line for any PHP developers out there.

Second, have you taken a look at any of the PHP libraries for some ideas as to how they do it? I'm not a PHP dev so I am afraid I am not much help.

try: api_key=' . $apikey

instead of: api_key' . $apikey

ohh, and get a new API key, that one's public now :)

P.S. I just removed the API key from the original post.

Kan du ikke finde en film eller TV-serie? Log in og opret den.

Global

s focus the search bar
p open profile menu
esc luk et åbent vindue
? open keyboard shortcut window

På mediesider

b go back (or to parent when applicable)
e go to edit page

On TV season pages

(right arrow) go to next season
(left arrow) go to previous season

On TV episode pages

(right arrow) go to next episode
(left arrow) go to previous episode

På alle billedesider

a open add image window

On all edit pages

t open translation selector
ctrl+ s submit form

På diskussionssider

n opret ny diskussion
w toggle watching status
p toggle public/private
c toggle close/open
a åben aktivitet
r reply to discussion
l go to last reply
ctrl+ enter submit your message
(right arrow) next page
(left arrow) previous page

Indstillinger

Want to rate or add this item to a list?

Log ind