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?
Un film, une émission télévisée ou un artiste est introuvable ? Connectez-vous afin de créer une nouvelle fiche.
Vous souhaitez évaluer ou ajouter cet élément à une liste ?
Pas encore membre ?
Réponse de Travis Bell
le 6 février 2016 à 09h59
Hi jakothan,
I'm not sure what would be causing that, I just tested my browser (like you mentioned) as as well as cURL:
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.
Réponse de jakothan
le 7 février 2016 à 09h52
Hey Travis. Sorry, my mistake. Should read the docu BEFORE I start coding. :( I've forgot the cURL Header. :/ Works fine. Thank you. ;)
Réponse de jakothan
le 7 février 2016 à 11h06
One more question / problem... I'm using PHP foreach to recieve informations from TMDB. I found this in the docu:
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. :(
Réponse de Travis Bell
le 8 février 2016 à 09h38
Hi,
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 thepage=2
parameter.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 theoriginal_language
field) and the translated title if present and different can be find with thetitle
field.Réponse de jakothan
le 8 février 2016 à 09h54
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...
Réponse de Travis Bell
le 8 février 2016 à 10h07
If the results are empty we must not have the movies added.
With regards to the translations, can you post some URLs with examples?
Réponse de jakothan
le 8 février 2016 à 11h30
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.
Réponse de jakothan
le 9 février 2016 à 09h53
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();
Réponse de Travis Bell
le 9 février 2016 à 10h22
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.
Réponse de wtfzdotnet
le 19 février 2016 à 17h16
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!
Réponse de jakothan
le 22 février 2016 à 05h48
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... :/