I am using the below CURL Function and can not figure out why it is not
retruning the results from the post. Can anyone take a look and tell
me what I may be doing wrong? I am just not seeing it.
As you can see at the bottom of the script if (strstr($Line, 'HOUSTON
YAMAHA MOTORSPORTS')) then it is reading the correct page, otherwise if
(strstr($Line, 'Yamaha Dealer Locator')) then it is reading the
incorrect page of the initial URL called
http://www.yamaha-motor.com/sport/de....aspx?ls=sport.
So when I run it what appears to be happening is the it is finding the
but not he returned page from the post.
It is a fairly simple script. Your help is much appreciated on how I
can resolve this issue.
Thank you.
<?php
$data="MasterTe mplate:_PageTem plate:cphCenter Content:CenterC ontent:fcDropDo wnList=ATVs&Mas terTemplate:_Pa geTemplate:cphC enterContent:Ce nterContent:zip TextBox=77090";
curlgrabber("ht tp://www.yamaha-motor.com/sport/dealers/dealerhome/home.aspx?ls=sp ort",
$data); // Calls The CURL Function
unset($data);
function curlgrabber ($url, $data)
{
// create a new curl resource
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch , CURLOPT_URL, $url);
curl_setopt($ch , CURLOPT_RETURNT RANSFER, true);
curl_setopt($ch , CURLOPT_FOLLOWL OCATION, true);
curl_setopt($ch , CURLOPT_CONNECT TIMEOUT, 600);
curl_setopt($ch , CURLOPT_TIMEOUT , 600);
curl_setopt($ch , CURLOPT_POST, true);
curl_setopt($ch , CURLOPT_POSTFIE LDS, $data);
// grab URL, and return output
$Contents = curl_exec($ch);
// close curl resource, and free up system resources
if (curl_errno($ch )) {
print curl_error($ch) ;
} else {
curl_close($ch) ;
unset($ch);
}
$Lines = preg_split("/\n/",$Contents );
$counter=0;
$strTag="False" ;
foreach($Lines as $Line)
{
if (strstr($Line, 'HOUSTON YAMAHA MOTORSPORTS')) // EXAMPLE ONLY!
{
echo "Post Worked And Is Reading Correct Page";
}
if (strstr($Line, 'Yamaha Dealer Locator')) // EXAMPLE ONLY!
{
echo "Post did not work. This is reading the initial screen at
http://www.yamaha-motor.com/sport/dealers/dealerhome/home.aspx?ls=sp ort";
}
}// End For Each
}// End Function
?>
retruning the results from the post. Can anyone take a look and tell
me what I may be doing wrong? I am just not seeing it.
As you can see at the bottom of the script if (strstr($Line, 'HOUSTON
YAMAHA MOTORSPORTS')) then it is reading the correct page, otherwise if
(strstr($Line, 'Yamaha Dealer Locator')) then it is reading the
incorrect page of the initial URL called
http://www.yamaha-motor.com/sport/de....aspx?ls=sport.
So when I run it what appears to be happening is the it is finding the
but not he returned page from the post.
It is a fairly simple script. Your help is much appreciated on how I
can resolve this issue.
Thank you.
<?php
$data="MasterTe mplate:_PageTem plate:cphCenter Content:CenterC ontent:fcDropDo wnList=ATVs&Mas terTemplate:_Pa geTemplate:cphC enterContent:Ce nterContent:zip TextBox=77090";
curlgrabber("ht tp://www.yamaha-motor.com/sport/dealers/dealerhome/home.aspx?ls=sp ort",
$data); // Calls The CURL Function
unset($data);
function curlgrabber ($url, $data)
{
// create a new curl resource
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch , CURLOPT_URL, $url);
curl_setopt($ch , CURLOPT_RETURNT RANSFER, true);
curl_setopt($ch , CURLOPT_FOLLOWL OCATION, true);
curl_setopt($ch , CURLOPT_CONNECT TIMEOUT, 600);
curl_setopt($ch , CURLOPT_TIMEOUT , 600);
curl_setopt($ch , CURLOPT_POST, true);
curl_setopt($ch , CURLOPT_POSTFIE LDS, $data);
// grab URL, and return output
$Contents = curl_exec($ch);
// close curl resource, and free up system resources
if (curl_errno($ch )) {
print curl_error($ch) ;
} else {
curl_close($ch) ;
unset($ch);
}
$Lines = preg_split("/\n/",$Contents );
$counter=0;
$strTag="False" ;
foreach($Lines as $Line)
{
if (strstr($Line, 'HOUSTON YAMAHA MOTORSPORTS')) // EXAMPLE ONLY!
{
echo "Post Worked And Is Reading Correct Page";
}
if (strstr($Line, 'Yamaha Dealer Locator')) // EXAMPLE ONLY!
{
echo "Post did not work. This is reading the initial screen at
http://www.yamaha-motor.com/sport/dealers/dealerhome/home.aspx?ls=sp ort";
}
}// End For Each
}// End Function
?>
Comment