Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP/Curl Authentication

Status
Not open for further replies.

FinnMan

Technical User
Feb 20, 2001
75
US
I have to ask for help before I go insane :p
*********************************************

I have the following curl script (works great) which I'm trying to convert to PHP/Curl. Any pointers on what I'm doing wrong would be great.


curl -s -u username:password -k -F userid=username
Below is my php code that basically bombs because it says I'm not authenticated OR it doesn't understand my credentials.


<?php
$url = ' $params = "UserName=user&Password=password";
$user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";

$ch = curl_init();
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
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_SSL_VERIFYPEER, FALSE);
$result=curl_exec ($ch);
curl_close ($ch);
echo("Results: <br>".$result);
?>

***********************************

Suggestions?
 
Disregard. I just found it. I had to drop the postfields option and use CURLOPT_USERPWD

./FM
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top