473,397 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Need authentication while reading file.

TheMadMidget
I'm trying to use something like file_get_contents() but on a file that requires a username and password.

Thanks,
Jason
Oct 30 '06 #1
2 1136
vssp
268 100+
H i

Sorry i am clar can u expline breifly?

vssp
Nov 2 '06 #2
I want source from a page so I was using file_get_contents(), but it comes back as Unathorized Access, because it needs a username and password to access the page. Last night I found a way to do with cURL, but if there is a simpler method, that would be nice.

[PHP]
$url = 'http://url.goes.here.com';
$user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";

$ch = curl_init();
curl_setopt($ch, CURLOPT_USERPWD, "username:password");
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, TRUE);
curl_setopt($ch, CURLOPT_MUTE, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$result=curl_exec ($ch);
curl_close ($ch);
[/PHP]

Everything comes back in $result, I may have a few extra curl_setopt() but it works.

Jason
Nov 2 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Rob | last post by:
I have an ASP.NET application that uses forms-based authentication. A user wishes to be able to run multiple sessions of this application simultaneously from the user's client machine. The...
4
by: Chris Gatto | last post by:
Hi, I'm having what should be a minor problem but has turned into a 2 day slug fest with ASP.Net. I am simply attempting to authenticate my asp.net application users against users in an AD...
1
by: Shapper | last post by:
Hello, I am developing a web site where half of the pages are public and the other half are accessible only to registered users. The pages which are accessible only to registered users have...
20
by: Shanta McBain | last post by:
Hi I am running Mandrake 10 and would like to get sql-ledger to access the database. I can get in to the database with a local user at the command prompt and Web Admin. sql-ledger returns...
1
by: LP | last post by:
Hello, I am really hoping someone can help me here. I have a web service running on Win 2003 IIS 6.0, and VB6 client connecting to it with the use of Soap Toolkit. Everything worked fine until I...
3
by: Miguel Dias Moura | last post by:
Hello, I am working on an Asp.Net 2.0 / SQL 2005 web project where: 1. All users must login. 2. There will be two user types: student and professor. The students and professors are not related....
3
by: Darrel | last post by:
I'm reading up on some tutorials on using forms authentication in ASP.net 2.0 I'm confused. In 1.1, I created a table in my DB for users, wrote a page for the login form, then added this to...
2
by: rcp | last post by:
Hi all, I've read all posts from all existing threads and none of them worked to solve my problem, although its exactly the same. I'll try to explain my case and see if a kind soul could help me...
0
by: Phils | last post by:
Hello guys; I i have just found the solution to my problem but would like to full understand the solution so would be great full if you could enlighten me. OUR Set-up
18
by: troywalker | last post by:
I am new to LDAP and Directory Services, and I have a project that requires me to authenticate users against a Sun Java System Directory Server in order to access the application. I have found...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.