Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8016543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:34:00+00:00 2026-06-04T20:34:00+00:00

I am using Curl in PHP to call an API . According to their

  • 0

I am using Curl in PHP to call an API.

According to their documentation, they are returning “Authentication-Callback” within the returned page’s header.

It works perfectly when I paste the URL into the browser, but Curl seems to leave it out.

Here is my code

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'http://api.themoviedb.org/3/authentication/token/new?api_key=[MY_API_KEY]&language=en');
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_FAILONERROR, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    $results = curl_exec($ch);
    $headers = curl_getinfo($ch);

Here is the returned header

Array
    (
        [url] => http://api.themoviedb.org/3/authentication/token/new?api_key=[MY_API_KEY]&language=en&
        [content_type] => application/json;charset=utf-8
        [http_code] => 200
        [header_size] => 470
        [request_size] => 137
        [filetime] => -1
        [ssl_verify_result] => 0
        [redirect_count] => 0
        [total_time] => 0.109
        [namelookup_time] => 0
        [connect_time] => 0.047
        [pretransfer_time] => 0.047
        [size_upload] => 0
        [size_download] => 116
        [speed_download] => 1064
        [speed_upload] => 0
        [download_content_length] => 116
        [upload_content_length] => 0
        [starttransfer_time] => 0.109
        [redirect_time] => 0
        [certinfo] => Array
            (
            )

    )

As far as I can tell, everything is right. Curl returns the data that I need perfectly, just not the correct headers.

Any help is appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T20:34:01+00:00Added an answer on June 4, 2026 at 8:34 pm

    What you’re doing right now is getting stored information about the header via curl_getinfo() which only gets the information in the OPT list on that page.

    What you should do instead is to return the header and then manually separate it:

    curl_setopt($ch, CURLOPT_HEADER, 1);
    // The rest of your options
    $output = curl_exec($ch);
    
    // Since the end of the header is always delimited by two newlines
    $output = explode("\n\n", $output, 2);
    $header = $output[0];
    $content = $output[1];
    

    This is more work but will get you the real headers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using curl to call a web service API. The service can unresponsive
I have to scrape this page using php curl. In this when the user
i wanna using curl in php script and run it in command line mode.
I'm using curl in PHP to check the HTTP code when requesting some files,
I'm using curl to make php send an http request to some website somewhere
How can I do a RAW POST in PHP using cURL? Raw post as
I have a need to rename a file after download using php cURL. Here's
Im using curl to fetch my Twitter favorites: <?php $username = bob; $password =
I'm trying to get character data from www.wowarmory.com using PHP and cURL. The code
I'm using php 5.3.2 and when i execute a curl it display the result

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.