The Movie Database-ondersteuning

Hey, I'm using this request to find a movie by name. http://api.themoviedb.org/3/search/movie?api_key=xxx xxx&query=Starship+Troopers+2%3A+Hero+of+the+Federation&year=2004&language=de

When I put this URL directly into the browser, I will see all the informations as json. But when I send the request by a PHP Script, I only recieve an error 400 - Bad request. Can anybody help?

11 antwoorden (op pagina 1 van 1)

Jump to last post

Hi jakothan,

I'm not sure what would be causing that, I just tested my browser (like you mentioned) as as well as cURL:

$ curl -v "http://api.themoviedb.org/3/search/movie?api_key=###&query=Starship+Troopers+2%3A+Hero+of+the+Federation&year=2004&language=de"
*   Trying 54.83.9.204...
* Connected to api.themoviedb.org (54.83.9.204) port 80 (#0)
> GET /3/search/movie?api_key=###&query=Starship+Troopers+2%3A+Hero+of+the+Federation&year=2004&language=de HTTP/1.1
> Host: api.themoviedb.org
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: *
< Cache-Control: public, max-age=21600
< Content-Type: application/json;charset=utf-8
< Date: Sat, 06 Feb 2016 14:54:24 GMT
< ETag: b706835de79a2b4e80506f582af3676a
< Server: openresty
< X-RateLimit-Limit: 40
< X-RateLimit-Remaining: 39
< X-RateLimit-Reset: 1454770474
< Content-Length: 999
< Connection: keep-alive
<
* Connection #0 to host api.themoviedb.org left intact
{"page":1,"results":[{"poster_path":"\/dkE7T7C6R8wSHoYkXypLcPtODlO.jpg"...

And indeed it worked fine as well.

You could take a look at what the php-tmdb library is doing and see if it's causing an error there. If not, compare the two and see the difference.

Hey Travis. Sorry, my mistake. Should read the docu BEFORE I start coding. :( I've forgot the cURL Header. :/ Works fine. Thank you. ;)

One more question / problem... I'm using PHP foreach to recieve informations from TMDB. I found this in the docu:

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://api.themoviedb.org/3/search/movie?api_key='.$apikey.'&query='.urlencode($ITEM[1]).'&year='.$ITEM[7].'&language='.$language.' ');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);

curl_setopt($ch, CURLOPT_HTTPHEADER, array(
      "Accept: application/json"
));

$response = curl_exec($ch);
curl_close($ch);

But I recieve informations for only 1 of 34 movies. All the others are empty. And the one is in english, not german, but I set the language to de. :(

Hi,

But I recieve informations for only 1 of 34 movies

Do you mean the search results are returning 34 movies and you're only getting the first? Search results are returned in the results field. This is an array, so you'll have to iterate over each item. We only return 20 items per page so you will have to query the second page by using the page=2 parameter.

And the one is in english, not german, but I set the language to de

The overview field will be empty if there is no translation added to the language you are querying. original_title can be any language (most often tied to the original_language field) and the translated title if present and different can be find with the title field.

Hi, no, I have actually a movie list with 34 movies. I'll try to send a request for each movie to get informations from tmdb. 33 results are empty, one has the informations. When I call the URL directly in my browser, I will see the german translations for most of the movies. Only one or two are'nt translated...

If the results are empty we must not have the movies added.

With regards to the translations, can you post some URLs with examples?

I'am afraid that I have an issue in my request, but I could'nt figure out where... When I remove the language part from my request, I recieve the same result. 33 of 34 results are empty. And I've checked the movies at your site, and most of them are translated, e.g. "Project X", "Starship Troopers 2" or "The New Adventures of Pippi Longstocking". The result at my site looks like this: Es gibt 34 Titel in der Datei.

string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(1785) "{"page":1,"results":[{"poster_path":null,"popularity":1.002741,"id":3062,"backdrop_path":null,"vote_average":0,"overview":"Abby is an American sitcom shown on UPN from January 6, 2003 to March 4, 2003. The show's original title, Abby Walker, was soon changed.","first_air_date":"2003-01-06","origin_country":["US"],"genre_ids":[],"original_language":"en","vote_count":0,"name":"Abby","original_name":"Abby"},{"poster_path":null,"popularity":1,"id":42657,"backdrop_path":null,"vote_average":0,"overview":"","first_air_date":"","origin_country":[],"genre_ids":[],"original_language":"en","vote_count":0,"name":"About Abby","original_name":"About Abby"},{"poster_path":null,"popularity":1.000006,"id":6277,"backdrop_path":null,"vote_average":0,"overview":"My Guardian Abby is a drama series that is broadcast on QTV-11 starring Starstruck avenger Nadine Samonte as Abby, a pink angel.\n\nEvery week, the show features different guest stars with different plots. In the story, there are three types of angels: white angels, child angels that stay in heaven; pink angels, who go down to earth to help mortals; and the blue angels, who help the pink angels in their mission. Pauleen, a blue angel, acts as Abby's guide whenever she has to go down and aid the mortals, and in the process, teaching her all about life.","first_air_date":"","origin_country":["PH"],"genre_ids":[18],"original_language":"en","vote_count":0,"name":"My Guardian Abby","original_name":"My Guardian Abby"},{"poster_path":null,"popularity":1,"id":30978,"backdrop_path":null,"vote_average":0,"overview":"","first_air_date":"","origin_country":[],"genre_ids":[],"original_language":"en","vote_count":0,"name":"Abby's Flying Fairy School","original_name":"Abby's Flying Fairy School"}],"total_results":4,"total_pages":1}" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) ""

the output is from var_dump($result) from the docu.

I've tried another way. I'm using the IMDb ID now instead the movie name. But it's the same result. Every request is empty now. :( Any idea what I can change? This is my request now:

$ch = curl_init();

    curl_setopt_array($ch, Array(
        CURLOPT_URL             => 'http://api.themoviedb.org/3/find/'.$xml[imdbID].'?external_source=imdb_id&api_key='.$apikey.'&language='.$language.' ',
        CURLOPT_RETURNTRANSFER  => TRUE,
        CURLOPT_HEADER          => FALSE,

        CURLOPT_HTTPHEADER, array(
      "Accept: application/json"
      )
    ));

    $tmdbreq = curl_exec($ch);
    curl_close($ch);

I don't know PHP so I can't be helpful on that front. I know we're returning the data so I can't offer much help unfortunately.

The only thing I can suggest is again, looking at the PHP lib I linked to above. It's actually a really good library and I would recommend using it.

Hi Jakothan,

I've found your thread through the github traffic page, I'm the author of the referenced lib. If the full OOP implementation is scary for you, I'd suggest taking a look at the alternative examples, they should provide the basic fundamentals you need :). ( They only return RAW answers of the API ).

https://github.com/php-tmdb/api/blob/2.0/examples/movies/api/all.php

There are many more examples available to get started!

Hi wtfzdotnet,

thanks for your reply. I've testet your lib for my little project, and it works fine so far. But the problem that I have is, that I couldn't figure out, how to "split" the find results. I have all the information in the "dump", but I was not able to get the "Title", "Overview" and "Poster" or "Backdrop". I also wrote at your G+ Site.. ;)

So I've spent some time with other things and startet on friday again with the "original code" from the TMDb docu. And what should I say? It works! I don't know why, because I didn't changed anything... :/

Film of tv-serie niet gevonden? Meld je aan om deze toe te voegen.

Wereldwijd

s focus op zoekbalk
p open profielmenu
esc sluit een open venster
? open sneltoetsen venster

Op media pagina's

b ga terug (of ga naar bovenliggend item)
e ga naar beweken

Op tv-seizoenspagina's

(rechter pijl) ga naar volgende seizoen
(linker pijl) ga naar vorig seizoen

Op pagina's met tv-series

(rechter pijl) ga naar volgende aflevering
(linker pijl) ga naar vorige aflevering

Op alle afbeeldingspagina's

a open venster afbeelding toevoegen

Op alle bewerkte pagina's

t open vertaalmenu
ctrl+ s verstuur formulier

Op discussiepagina's

n start nieuwe discussie
w Verander kijk status
p privé of openbaar
c schakelen sluiten/openen
a open activiteit
r beantwoord discussie
l ga naar laatste antwoord
ctrl+ enter verstuur uw bericht
(rechter pijl) volgende pagina
(linker pijl) vorige pagina

Instellingen

Want to rate or add this item to a list?

Inloggen