תמיכת The Movie Database

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!

.לא מצאת סרט או סדרה? היכנס כדי ליצור אותם

עולמי

s התמקד בשורת החיפוש
p פתח תפריט פרופיל
esc סגור חלון פתוח
? פתח חלון קיצורי דרך של מקלדת

בדפי מדיה

b לך חזרה (או אל הורה אם ישים)
e לך אל דף עריכה

בדפי עונות

(חץ ימני) לך אל העונה הבאה
(חץ שמאלי) לך אל העונה הקודמת

בדפי סדרות

(חץ ימני) לך אל הפרק הבא
(חץ שמאלי) לך אל הפרק הקודם

בכל דפי תמונה

a פתח חלון הוספת תמונה

בכל דפי עריכה

t פתח בוחר תרגום
ctrl+ s הגש טופס

בדפי דיון

n צור דיון חדש
w עורר מעמד צפייה
p עורר ציבורי/פרטי
c עורר סגירה/פתיחה
a פתח פעילות
r השב אל דיון
l לך אל תשובה אחרונה
ctrl+ enter הגש את הודעתך
(חץ ימני) הדף הבא
(חץ שמאלי) הדף הקודם

הגדרות

?רוצה לדרג או להוסיף פריט אל רשימה

היכנס