The Movie Database Support

Hello, i have a problem how to make to apear Top Billed Cast all with his photo, json is working but credits and variables it is the same on every character.

5 replies (on page 1 of 1)

Jump to last post

Hi @seedfile

If you query the /movie/credits all you need to do is iterate over the cast array. Each item contains the person, character name and profile image for the movie.

Here's some quick Ruby code showing you the first 4 credits from Fight Club (just as an example):

require 'uri'
require 'net/http'

url = URI("https://api.themoviedb.org/3/movie/550/credits?api_key=###")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
response = http.request(request)
parsed_json = JSON.parse(response.read_body)
2.2.3 :039 >   parsed_json['cast'].first(4).map { |item| "#{item['name']} (#{item['character']})" }
 => ["Edward Norton (The Narrator)", "Brad Pitt (Tyler Durden)", "Meat Loaf (Robert 'Bob' Paulson)", "Jared Leto (Angel Face)"]

I have writed this code....

$movcredits = json_decode(file_get_contents("https://api.themoviedb.org/3/movie/$tmdbmovie/credits?api_key=###"), true);

echo $movcredits["credits_id"];

and didn't working...

Take a look at the response you're getting back, there is no key called credits_id in the root of the JSON object. You need to first access the cast array, then iterate over each item like I did above .

echo $movcredits["cast"][0];

dind't work, have you another php solution like my?

I don't know PHP, so I can't be very helpful with that. There's 2 things I suggest at this point:

  1. Take a look at the TMDb PHP library
  2. You might have better luck posting on something like StackOverflow as the problem here is code related, and not TMDb service related.

Cheers.

Can't find a movie or TV show? Login to create it.

Global

s focus the search bar
p open profile menu
esc close an open window
? open keyboard shortcut window

On media pages

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

On all image pages

a open add image window

On all edit pages

t open translation selector
ctrl+ s submit form

On discussion pages

n create new discussion
w toggle watching status
p toggle public/private
c toggle close/open
a open activity
r reply to discussion
l go to last reply
ctrl+ enter submit your message
(right arrow) next page
(left arrow) previous page

Settings

Want to rate or add this item to a list?

लॉगिन