cURL – PHP implementation

<?php

// FIND BOOKS ON PHP AND MYSQL ON AMAZON

$url http://www.amazon.com/exec/obidos/search-handle-form/002-5640957-2809605&#8221;;

$ch curl_init();    // initialize curl handle

curl_setopt($chCURLOPT_URL,$url); // set url to post to

curl_setopt($chCURLOPT_FAILONERROR1);

curl_setopt($chCURLOPT_FOLLOWLOCATION1);// allow redirects

curl_setopt($chCURLOPT_RETURNTRANSFER,1); // return into a variable

curl_setopt($chCURLOPT_TIMEOUT3); // times out after 4s

curl_setopt($chCURLOPT_POST1); // set POST method

curl_setopt($chCURLOPT_POSTFIELDS“url=index%3Dbooks&field-keywords=PHP+MYSQL”); // add POST fields

$result curl_exec($ch); // run the whole process

curl_close($ch); 

echo $result;

?>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s