cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Newbie PHP/Curl Problem

From: Alistair Ross <ali_at_woollyfoot.org>
Date: Mon, 3 Nov 2003 15:23:00 -0000 (GMT)

Hi all,

I've written the following in PHP but my university aren't willing to
install the curl module for PHP so i need to make an external call to the
command line curl program. I've tried loads of ways but just can't get it
to behave in the same way as my PHP script does.

The PHP is:

<?php

        $isbn="0446394319";

        // use curl to retrieve the search results

        $url =
"http://www.amazon.com/exec/obidos/search-handle-form/002-5640957-2809605";
        $ch = curl_init(); // initialize curl handle
        #curl_setopt($ch, CURLOPT_VERBOSE, 1);
        curl_setopt($ch, CURLOPT_URL, $url); // set url
        curl_setopt($ch, CURLOPT_FAILONERROR, 1); // it had better not error!
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirection
if url changes
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return it to a
variable
        curl_setopt($ch, CURLOPT_TIMEOUT, 3); // timeout of 3s just in case
        curl_setopt($ch, CURLOPT_POST, 1); // set method to POST
        curl_setopt($ch, CURLOPT_POSTFIELDS,
"url=index%3Dbooks&field-keywords=$isbn"); // add search string to
POST
        $result = curl_exec($ch); // run the whole darn thing
        curl_close($ch); // close curl handle

        echo $result;

        ?>

My attempts at the commandline code can't seem to follow the re-directs
properly and end up just GETting the search input page.

Thanks in advance for your help.

Alistair

-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive? Does it
help you create better code? SHARE THE LOVE, and help us help
YOU! Click Here: http://sourceforge.net/donate/
Received on 2003-11-03