I am using a class called snoopy which fetches links from a remote web page. I am able to use it to fetch links, but when I try to fetch links from the actual page that I need to fetch the links from I get the following error.
** Question
Does anyone know what the http response code unauthorized means? Could this have something to do with the referrer of the page or the long string in the URL? I have no problem fetching links from a domain such as http://www.domain.com.
I also wondering why it says the variable that was passed is not an array or object.
response code: HTTP/1.1 401 Unauthorized
Warning: Variable passed to each() is not an array or object in /home/content/a/l/e/directory/html/gregsCode/test.php on line 58
This is the code that I am using to call the snoopy class.
include "Snoopy.class.php";
$snoopy = new Snoopy;
if($snoopy->fetchlinks("https://www.domain.com/members/powersearch/control/interresults?fromyear=2007&toyear=2008®ion=&make=&modeltext=&auction=&numresultsperpage=50&x=33&y=4&mileage=&interior=&engine=&top=&transmission=&radio=&certification=&consignor=&presalechannel=1&dealerexchangechannel=5&cyberlotchannel=2&cyberauctionchannel=4&encorechannel=3&numresultsperpage=50"))
{
echo "response code: ".$snoopy->response_code."<br>\n";
while(list($key,$val) = each($snoopy->results))
echo $key.": ".$val."<br>\n";
echo "<p>\n";
echo "<PRE>".htmlspecialchars($snoopy->results)."</PRE>\n";
}
else
echo "error fetching document: ".$snoopy->error."\n";
To get the code that is in the snoopy class go to http://snoopy.sourceforge.net.
There is another issue that I am dealing with when I am retrieving links.
I have noticed that some of the links that I have to retrieve are not normal links. they are written with JAVA script and look like this.
<a href="javascript:goToPresaleResults('18', 'ALBA', '05/02/2007', '05%2F02%2F2007+Albuquerque+AA+-+GM+SALE', '1');">82 Found</a>
** Question
Is there a particular php function that will be able to fetch this link, or at least fetch each variable that is in the link? I can build the url in a php script.
There is also a function that these links call. Here is the function.
function goToPresaleResults(saleID, auctionID, saleDate, iResultName, saleChannel)
{
document.PSPageSelector.action = "/members/presale/control/powersearchList"; // this is the url of the script.
document.PSPageSelector.saleID.value = saleID;
document.PSPageSelector.saleNumber.value = saleID;
document.PSPageSelector.saleDate.value = saleDate;
document.PSPageSelector.auctionID.value = auctionID;
if(auctionID == null || auctionID == ''){
loadOriginalAuctions();
}else{
clearAuctions();
}
document.PSPageSelector.salechannel.value = saleChannel;
document.PSPageSelector.irname.value = iResultName;
checkEngineValue();
document.PSPageSelector.submit();
return;
}