The Movie Database Support

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 replies (on page 1 of 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!

Can't find a movie or TV show? Login to create it.

Global

s focus the search bar
p open profile menu
esc close an open window
? open keyboard shortcut window

On media pages

b go back (or to parent when applicable)
e go to edit page

On TV season pages

(right arrow) go to next season
(left arrow) go to previous season

On TV episode pages

(right arrow) go to next episode
(left arrow) go to previous episode

On all image pages

a open add image window

On all edit pages

t open translation selector
ctrl+ s submit form

On discussion pages

n create new discussion
w toggle watching status
p toggle public/private
c toggle close/open
a open activity
r reply to discussion
l go to last reply
ctrl+ enter submit your message
(right arrow) next page
(left arrow) previous page

Settings

Want to rate or add this item to a list?

Login