دعم الموقع

I'm a total beginner here, so I apologize if this seems like a basic question. I'm trying to get the cast list after finding the id of a film. I can successfully get the original JSON info and extract the id, but when I try to call for the cast list, I get an error telling me I have an invalid API key. I have a key (which I use to get the original info), but it seems the documentation tells me how to get this with the "mock server info". My request shows up in the inspector, but I'm obviously missing something. My javascript as of now looks something like...

$(document).ready(function() {

  var getLists = function(){
    var filmA = $('#filmA').val();
    var filmB = $('#filmB').val();

    $('#return-list').html("<h2 class='loading'>Searching</h2>");

    $.getJSON("http://api.themoviedb.org/2.1/Movie.search/en/json/###/" + filmA + "?callback=?", function(json){
        var filmAid = json[0].id;
        console.log(json);
        console.log(filmAid);
        var xhr = new XMLHttpRequest();
        xhr.open("GET", "http://private-e886-themoviedb.apiary.io/3/movie/" + filmAid + "/casts");
        xhr.setRequestHeader("Accept", "application/json");
        xhr.onreadystatechange = function () {
          if (this.readyState == 4) {
            alert('Status: '+this.status+'\nHeaders: '+JSON.stringify(this.getAllResponseHeaders())+'\nBody: '+this.responseText);
          }
        };
        xhr.send(null);
      }
    );

    $.getJSON("http://api.themoviedb.org/2.1/Movie.search/en/json/###/" + filmB + "?callback=?", function(json){
        var filmBid = json[0].id;
        console.log(json);
        console.log(filmBid);
        $.getJSON()
      }
    );

  };

  $('#search').click(getLists);

});

Obviously, I'm ideally trying to get the cast list for two movies and compare them, but I'm hung up on just getting the cast list. Like I said, I'm sure this is a basic problem, but any input is greatly appreciated.

Thanks!

2 ردود (على هذه الصفحة 1 من 1)

Jump to last post

Hi airguitarbandit,

There's a few things worth mentioning here.

First, I see you're mentioning the mock server (and see you using Apiary on the .open call) but you are still calling 2.1 in your initial call?

Secondly, why are you using 2.1? It's been EOL'd for over a year. Developing anything on it now would be a waste of your time.

Third, depending what you're trying to do this post might help you out at well: https://www.themoviedb.org/talk/511be2b519c295166f03214f

Cheers.

Thanks Travis!

I also see now there are 3 pound signs in that url, which I'm assuming is where I put my api key. I don't know why I didn't see that before. I must have just been getting tired and not paying attention. I also realize now I was using 2.1 because I was following along with this tutorial: http://coding.smashingmagazine.com/2012/02/09/beginners-guide-jquery-based-json-api-clients/

I actually was able to get it working (or at least the first stages) with the RottenTomatoes API, but I may give it a shot with this again now that I have some answers.

Thanks so much for your healp, Steve

لم تجد الفلم أو المسلسل ؟ سجل دخولك و انشئها

عام

s ركز شريط البحث
p افتح قائمة الملف الشخصي
esc اغلق النافذة المفتوحة
? افتح نافذة اختصارات لوحة المفاتيح

على كافة صفحات الوسائط

b ارجع للخلف (او للصفحة الام عند التطبيق)
e انتقل لصفحة التعديل

على كافة صفحات موسم المسلسل

(السهم الايمن) انتقل للموسم التالي
(السهم الايسر) انتقل للموسم السابق

على كافة صفحات حلقة المسلسل

(السهم الايمن) انتقل للحلقة التالية
(السهم الايسر) انتقل للحلقة السابقة

على كافة صفحات الصور

a افتح صفحة اضافة الصورة

على كافة صفحات التعديل

t افتح محدد الترجمة
ctrl+ s ارسال النموذج

على صفحات المناقشة

n انشى نقاش جديد
w تبديل حالة المتابعة
p تبديل عام / خاص
c تبديل اغلاق / فتح
a افتح الانشطة
r رد على النقاش
l انتقل لأخر رد
ctrl+ enter أرسل رسالتك
(السهم الايمن) الصفحة التالية
(السهم الايسر) الصفحة السابقة

الاعدادات

هل تريد تقييم او اضافة هذا العنصر للقائمة؟

تسجيل الدخول