Soporte de The Movie Database

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 respuestas (en la página 1 de 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.

¿No encuentras una película o serie? Inicia sesión para crearla:

Global

s centrar la barra de búsqueda
p abrir menú de perfil
esc cierra una ventana abierta
? abrir la ventana de atajos del teclado

En las páginas multimedia

b retrocede (o a padre cuando sea aplicable)
e ir a la página de edición

En las páginas de temporada de televisión

(flecha derecha) ir a la temporada siguiente
(flecha izquierda) ir a la temporada anterior

En las páginas de episodio de televisión

(flecha derecha) ir al episodio siguiente
(flecha izquierda) ir al episodio anterior

En todas las páginas de imágenes

a abrir la ventana de añadir imagen

En todas las páginas de edición

t abrir la sección de traducción
ctrl+ s enviar formulario

En las páginas de debate

n crear nuevo debate
w cambiar el estado de visualización
p cambiar público/privado
c cambiar cerrar/abrir
a abrir actividad
r responder al debate
l ir a la última respuesta
ctrl+ enter enviar tu mensaje
(flecha derecha) página siguiente
(flecha izquierda) página anterior

Configuraciones

¿Quieres puntuar o añadir este elemento a una lista?

Iniciar sesión