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 294839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:24:13+00:00 2026-05-12T06:24:13+00:00

I hope this is a relatively straight forward thing to do, and that my

  • 0

I hope this is a relatively straight forward thing to do, and that my google skills have simply failed me on this occasion. I have a BASIC authentication protected resource which I want to have PHP perform a POST HTTP request against.

I have tried injecting Authentication: Basic (encrypted u/p data) into the headers which didn’t appear to work – so I wonder, can the powers of Greyskull i mean StackOverflow provide any guidance.

$req .= "&cmd=_initiate_query";
$header = "POST /someendpoint HTTP/1.1\r\n".
        "Host:example.com\n".
        "Content-Type: application/x-www-form-urlencoded\r\n".
        "User-Agent: PHP-Code\r\n".
        "Content-Length: " . strlen($req) . "\r\n".
        "Connection: close\r\n\r\n";
$fp = fsockopen ('ssl://example.com', 443, $errno, $errstr, 30);
if (!$fp) {
    // HTTP ERROR
} else {
    fputs ($fp, $header . $req);
    while (!feof($fp)) {
        $result .= fgets ($fp, 128);
    }
    fclose ($fp);
}
  • 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-05-12T06:24:13+00:00Added an answer on May 12, 2026 at 6:24 am

    Using:

    $header = "POST /someendpoint HTTP/1.1\r\n".
            "Host:example.com\n".
            "Content-Type: application/x-www-form-urlencoded\r\n".
            "User-Agent: PHP-Code\r\n".
            "Content-Length: " . strlen($req) . "\r\n".
            "Authorization: Basic ".base64_encode($username.':'.$password)."\r\n".
            "Connection: close\r\n\r\n";
    

    Should work – are you sure it is a Basic authentication system? It may be worth watching the raw header data using something like CharlesProxy to ensure it is an authentication (and you’ll be then able to copy the authorization string as well!).

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

Sidebar

Related Questions

I hope this is a relatively easy problem although I have spent hours websearching
This should be relatively straight forward however I'm being swamped in SQL information whenever
I'm relatively new to web application programming so I hope this question isn't too
I have a relatively extensive sqlite database that I'd like to import into my
I'm relatively new to jquery, so I have what I hope will be a
I'm relatively new to Java, so I hope this isn't a dumb question. I
I realised this might be relatively niche, but maybe that's why this is good
Simple question I hope. If I have a set of data like this: Classification
I have what should be a relatively simple question that I can't seem to
Hope this is the right place to be asking this, so my apologies if

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.