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 пошаљи поруку
(стрелица надесно) следећа страница
(лева стрелица) претходна страница

Подешавања

Желите ли да оцените или додате ову ставку у листу?

Пријави се