You are here: Having Trouble With CURL Function, Please Help « PHP Programming Language « IT news, forums, messages
Having Trouble With CURL Function, Please Help

Posted by devranger on 12/13/06 18:44

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/dealers/dealerhome/home.aspx?ls=sport.


So when I run it what appears to be happening is the it is finding the
http://www.yamaha-motor.com/sport/dealers/dealerhome/home.aspx?ls=sport
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="MasterTemplate:_PageTemplate:cphCenterContent:CenterContent:fcDropDownList=ATVs&MasterTemplate:_PageTemplate:cphCenterContent:CenterContent:zipTextBox=77090";

curlgrabber("http://www.yamaha-motor.com/sport/dealers/dealerhome/home.aspx?ls=sport",
$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_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 600);
curl_setopt($ch, CURLOPT_TIMEOUT, 600);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $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=sport";
}


}// End For Each
}// End Function

?>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация