Need help for passing authorization information
Posted: Sat Nov 05, 2005 4:02 am
feyd | Please use
During execution of parseSearchAPI.php (at command-line) returns the following warning message:
Please let me know if you need any other information.
Any information on this would be helpful.
Thanks,
Shanthakumari.
feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
I have a http query API written in coldfusion will return a .csv file. My PHP script parses the .csv file returned by the coldfusion script. I need to give a default username and password to query the coldfusion API. How will I include the authorization information - username and password in my PHP file before opening the http URL?
Here is the [b]parseSearchAPI.php Code:[/b]Code: Select all
<?php
$parseSearchAPI = new parseSearchAPI;
$arr = $parseSearchAPI->parseFile("http://xxx-server/searchapi.cfm?string=rme");
print_r($arr);
class parseSearchAPI
{
function parseFile($filename)
{
$fhandle = fopen($filename,"r");
if ($fhandle)
{
while ($line = fgets($fhandle))
{
if ($line)
{
$elementArr = explode("\"", $line);
$firstPart = trim($elementArr[0]);
$newElementArr = explode(",", $firstPart);
$QueryArr[$newElementArr[0]] = trim($elementArr[1]);
}
}
}
fclose($fhandle);
return $QueryArr;
}
}
?>Code: Select all
PHP Warning: fopen(http://xxx-server/searchapi.cfm?string=rme): failed to open stream: HTTP request failed! HTTP/1.1 401 Authorization Required
in /parseSearchAPI.php on line 9
PHP Warning: fclose(): supplied argument is not a valid stream resource in /parseSearchAPI.php on line 24
Content-type: text/html
X-Powered-By: PHP/4.3.4Any information on this would be helpful.
Thanks,
Shanthakumari.
feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]