[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

How to authenticate file_get_contents?

Posted on 2010-04-05
3
Medium Priority
?
614 Views
Last Modified: 2012-05-09
Is there a way to authenticate a file_get_contents statement to retrieve a URL that is protected by .htaccess?
0
Comment
Question by:metalaureate
3 Comments
 
LVL 46

Expert Comment

by:tbsgadi
ID: 29882782
Have a look at the following:

http://corz.org/serv/tricks/htaccess.php?page=all

Gary
0
 
LVL 51

Accepted Solution

by:
Steve Bink earned 2000 total points
ID: 29885382
My first instinct is to say no, but it should be possible if you use a stream context.  When creating the context, add headers for authentication.

See here for more info:

http://us.php.net/manual/en/function.file-get-contents.php
http://us.php.net/manual/en/function.stream-context-create.php
http://us.php.net/manual/en/context.http.php
http://en.wikipedia.org/wiki/Basic_access_authentication#Example
0
 

Author Closing Comment

by:metalaureate
ID: 31710947
Thanks!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

612 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question