دعم الموقع

I am new to the use of APIs and am trying to rework an example I found for v2.1 or 3.0. I'm using jquery. Here is what I was using in 2.1: $.getJSON("http://api.themoviedb.org/2.1/Movie.search/en/json/API_KEY/" + film + "?callback=?", function (response) { ..etc...

How do I rephrase that for v3?

Thanks. Ed

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

Jump to last post

Hi Ed,

The updated API request paths are all documented on the documentation website. Make sure to read through and understand the differences.

Here's a quick movie search example you can see: http://dev.travisbell.com/play/tmdb.html

Please note you will have to enter your own API key. This is just mock code.

Thanks. Both your original and updated response were very helpful. Let me ask one questions to help me understand. (I now understand after seeing your example page and looking at the source. response.results[0].id is what I wanted. (I had expected response to be an array, but now I remember reading the "response" to the $.getJSON is a js object

  1. so if I do $.getJSON("https://api.themoviedb.org/3/search/movie?api_key=f8c4016803faf5e7f424abe98a04b8d9&query=fight+club", function (response) {

            console.log(response);
    

    }); I get the JSON data back and look at the data tree.

  2. if I try to then get the movie id out of the JSON, I am stumped. I have tried console.log(response[0].id) console.log(response[0]results[0].id) , console.log(results[0].id) and I always get an error. I must be reading the JSON "tree" wrong

Thanks for any help. I feel like understanding this will be the big hurdle for me to overcome in understanding how to use JSON and the API. ( at least I hope so.)

Ed

Ed,

Not sure if you have figured out your problem yet, but thought I could be of some help.

First I would recommend reading through a tutorial or two on JSON to understand the format. This page gives a nice brief introduction to JSON.

The search request you are making to the API returns 6 movies in the response. It seems like you are trying to get the ID of the first movie in the results (you can also loop through the movies as they are in an array). The search results are listed in the results (which is an array) property of the response JSON object.

Example to get the ID of the first movie returned in the search results:

console.log(response.results[0].id);

Jason: Thanks. Once I sorted out that "response" was an object and not an array but that it contains the array "results" I was all set. Thanks for the reply. Ed

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

عام

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

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

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

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

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

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

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

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

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

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

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

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

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

الاعدادات

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

تسجيل الدخول