Forum Moderators: coopster
This script seems to pull the entire page at $url.
$url = "http://inventory.overture.com/d/searchinventory/suggestion/";
$curl = curl_init ();
curl_setopt ($curl, CURLOPT_URL, $url);
curl_setopt ($curl, CURLOPT_HEADER, 0);
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec ($curl);
curl_close($curl);
print $result;
How do I POST data to this URL and then extract just the keywords and keyword counts from the overture tool? I'd like to take just that data and store it in a variable...
Thanks!
$url = "https://www.example.com/somescript.php";
$postfields = "function=$func&var2=$mid&var3=$value3&var4=$value4&var5=value5&";
// Creating an array of email addresses and their amounts.
$postfields .= "payment[]=someone@example.com$4.30&";
$postfields .= "payment[]=someone@example.c$3.54&";
$postfields .= "payment[]=someone@example.com$4.54&";
$postfields .= "payment[]=someone@example.com$5.54&";
// Initialising a new session and returns a CURL handle for use.
$ch = curl_init();
// Processing
$reply = api_process($ch, $url, $postfields, $error);
echo "<PRE> Access Reply:";
if (empty($error)) {
print_r($reply);
echo "</PRE>";
} else {
print_r($error);
echo "</PRE>";
exit();
}
function api_process($curl_handle, $url, $postfields, &$error)
{
curl_setopt($curl_handle, CURLOPT_URL, $url);
curl_setopt($curl_handle, CURLOPT_FAILONERROR, 1);
// Do not want the HEADER to be displayed in the output of this code.
curl_setopt($curl_handle, CURLOPT_HEADER, 0);
// Want CURL to actuall POST the information just as if you were posting it
// from a form instead of using GET or REQUEST methods.
curl_setopt($curl_handle, CURLOPT_POST, 1);
// Defined which data to actually post
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $postfields);
// Prevents CURL from following any header("Location: url") responses from
// the server that it has connected to. Since we want to process this transaction
// results ourself, we want to avoid this, so set this value to 0.
curl_setopt($curl_handle, CURLOPT_FOLLOWLOCATION, 0);
// Allows CURL to directly return the transfer instead of printing it out directly.
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
// Prevents SSL verification.<-- Remove if verification required.
curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl_handle, CURLOPT_SSL_VERIFYHOST, 0);
// Executes the predefined CURL session
$result = curl_exec ($curl_handle);
//$result = curl_multi_exec ($curl_handle);
// Capturing an error, if any.
$error = curl_error ($curl_handle);
return $result;
}
once you get result you would have to parse that information to extract the data that you need. Possibly using some of the Regular Expression Functions (Perl-Compatible) [ca.php.net]