پشتیبانی پایگاه داده‌ فیلم

Hey Guys, I am trying to get a query result with CURL but the response is always false. If I try it with my browser, I get a response (successfull query)

Heres what i have:

    function curling($method, $params){

        $query = http_build_query($params);
        $url = $this->api_url . '/' . $this->api_version .  '/search/' . $method .'?api_key='.$this->api_key .
            '&language='. $this->language . "&" .$query ;


        $ch = curl_init();
        if ($ch) {
            curl_setopt_array($ch, array(
                CURLOPT_URL => $url,
                CURLOPT_RETURNTRANSFER => true,
                CURLOPT_HEADER => true,
                CURLOPT_FAILONERROR => true,
                CURLOPT_HTTPHEADER => array(
                    'Accept: application/json',
                    'Content-type: application/json'
                ) ,
            ));
            if ($this->debug) {
                error_log("DEBUG: Calling URL: {$url}");
            }
            if (!empty($data) && is_array($data)) {
                if ($this->debug) {
                    error_log("DEBUG: POSTDATA: " . var_export($data, true));
                }
                curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
            }
            $results[] = curl_exec($ch);
            $results[] = curl_getinfo($ch);
            curl_close($ch);
    }

    return $results;

}

$return[0] is always "false" A generated API key looks like this: https://api.themoviedb.org/3/search/movie?api_key=5bbc08[......]7f9d8c&language=de-DE&query=Iron+Man This key works in my browser I requested a token for my "application", but the Name of the App is not displayed in my account. I also think that isn't necessary?!

I don't have a V-Server or anything yet, I just want to develop at my local maschine (windows)

Thanks for your help!

5 پاسخ (در صفحه 1 از 1)

Jump to last post

Hi @exa.byte

Can you paste the entire response body and response headers? I have a feeling your answer lies there. If I was to guess, you're not constructing the request fully and it's throwing back an invalid API key response (status code 7).

Hi, WOAH, that was quick. Thank you. Heres the $result array

How do I format just an array corectly? The Function above was formatted automatically :/ sorry for the view

array(2) { [0]=> bool(false) [1]=> array(26) { ["url"]=> string(112) "https://api.themoviedb.org/3/search/movie?api_key=5b[....]f9d8c&language=de-DE&query=Iron+Man" ["content_type"]=> NULL ["http_code"]=> int(0) ["header_size"]=> int(0) ["request_size"]=> int(0) ["filetime"]=> int(-1) ["ssl_verify_result"]=> int(1) ["redirect_count"]=> int(0) ["total_time"]=> float(0.235) ["namelookup_time"]=> float(0) ["connect_time"]=> float(0.11) ["pretransfer_time"]=> float(0) ["size_upload"]=> float(0) ["size_download"]=> float(0) ["speed_download"]=> float(0) ["speed_upload"]=> float(0) ["download_content_length"]=> float(-1) ["upload_content_length"]=> float(-1) ["starttransfer_time"]=> float(0) ["redirect_time"]=> float(0) ["redirect_url"]=> string(0) "" ["primary_ip"]=> string(14) "54.243.147.233" ["certinfo"]=> array(0) { } ["primary_port"]=> int(443) ["local_ip"]=> string(12) "192.168.3.42" ["local_port"]=> int(52262) } }

Thank you so far

Heh, unfortunately, that's not that useful. You should still be getting a response as it looks like the request completed. I want to see the response body.

I don't have any experience with PHP, I am just wanting to see the response you are getting back.

Hi, thanks for your help. The Response-Header would be just "false" I just found out the curl_error was "60" which is an SSL-Error. I changed the URL from https to http and now it works.

Thanks for your suggestion :)

Glad you sorted it out!

فیلم و نمایش تلویزیونی را نمی‌توانید پیدا کنید؟ به سیستم وارد شوید تا آن را ایجاد کنید.

Global

s تمرکز بر منوی جستجو
p منوی پروفایل باز شود
esc بستن پنجره باز
? پنجره میانبرهای صفحه‌کلید باز شود

در صفحات مدیا

b بازگشت به عقب (یا در صورت لزوم به منشا)
e برو به صفحه ویرایش

در صفحات فصل تلویزیونی

(فلش سمت راست) برو به فصل بعد
(پیکان سمت چپ) برو به نشست قبلی

در صفحات قسمت تلویزیونی

(فلش سمت راست) برو به قسمت بعد
(پیکان سمت چپ) برو به قسمت قبلی

در تمام صفحات تصویر

a پنجره افزودن تصویر باز شود

در تمام صفحات ویرایش

t انتخابگر ترجمه باز شود
ctrl+ s ثبت از

در صفحات بحث

n ایجاد بحث جدید
w تغییر وضعیت وضعیت تماشا
p تغییر وضعیت عمومی/خصوصی
c تغییر وضعیت بسته/باز
a گشایش صفحه فعالیت
r پاسخ به بحث
l برو به آخرین پاسخ
ctrl+ enter پیام خود را ثبت کنید
(فلش سمت راست) صفحه بعد
(پیکان سمت چپ) صفحه قبلی

تنظیمات

آیا می‌خواهید به این مورد امتیاز دهید یا به فهرست اضافه کنید؟

ورود