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

curl-and-php

cURL and secure server

From: Michael Sisson <msisson_at_webcoat.com>
Date: Mon, 08 Mar 2004 13:47:30 -0600

I realize I am pretty close to getting this working but is eluding me.
I will post the headers that I need to emulate and then the code I have
so far, and see if someone can't straighten me out.

headers
--------
https://www.myyellow.com/dynamic/services/servlet?CONTROLLER=com.yell.ec.inter.yfsratequote.http.controller.RateQuoteAPIController

POST
/dynamic/services/servlet?CONTROLLER=com.yell.ec.inter.yfsratequote.http.controller.RateQuoteAPIController
HTTP/1.1
Host: www.myyellow.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6)
Gecko/20040206 Firefox/0.8
Accept:
application/x-shockwave-flash,text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://www.webcoat.com/test.htm
Cookie: JSESSIONID=AMhKVVHU!-399961706!-1408236465!7001!-1;
MYU_PERM_USER_ID=********
Authorization: Basic Z3JlZW5tYW46dmlwd2ViMQ==
Content-Type: application/x-www-form-urlencoded
Content-Length: 210

HTTP/1.1 200 OK
Server: Netscape-Enterprise/4.1
Date: Mon, 08 Mar 2004 16:36:29 GMT
Content-Length: 3063
Set-Cookie: MYU_PERM_USER_ID=********; expires=Thursday, 10-May-2007
02:23:09 GMT; path=/
Connection: close

code
-----
<?php
/**
 * Example POST with PHP via socket.
 *
 * $str is the form field values (username=foobar,password=mypassword, etc.)
 */
if (!$_POST['submit'])
{
}
else
{
    $str .= 'requestid='.$_POST['requestid'].'&';
    $str .= 'originzip='.$_POST['originzip'].'&';
    $str .= 'destzip='.$_POST['destzip'].'&';
    $str .= 'weight0='.$_POST['weight0'].'&';
    $str .= 'shipClass0='.$_POST['shipClass0'].'&';
    $str .= 'weight1='.$_POST['weight1'].'&';
    $str .= 'shipClass1='.$_POST['shipClass1'].'&';
    $str .= 'weight2='.$_POST['weight2'].'&';
    $str .= 'shipClass2='.$_POST['shipClass2'].'&';
    $str .= 'weight3='.$_POST['weight3'].'&';
    $str .= 'shipClass3='.$_POST['shipClass3'].'&';
    $str .= 'ltldd='.$_POST['ltldd'].'&';
    $str .= 'payment='.$_POST['payment'].'&';
    $str .= 'submit=Submit';

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,
"https://www.myyellow.com/dynamic/services/servlet?CONTROLLER=com.yell.ec.inter.yfsratequote.http.controller.RateQuoteAPIController");
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    curl_setopt ($ch, CURLOPT_HTTPHEADER, Array("Content-Type:
application/x-www-form-urlencoded"));
    curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, '1');
   curl_setopt ($ch, CURLOPT_RETURNTRANSFER, '1');
    curl_setopt($ch, CURLOPT_USERPWD, "********:********");
    curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE
5.01; Windows NT 5.0)");
    curl_setopt($ch, CURLOPT_POSTFIELDS, $str);
    $result = curl_exec($ch);
    curl_close($ch);
    echo $result;

}

?>

<html><head><title>Test</title></head><body>
<FORM ACTION="test2.php" method="post">
Origin Zip<br>

<input type="hidden" name="requestid" value="">

<input type="text" name="originzip" value="" size="6" maxlength="6"
tabindex="1"><br>
Destination Zip<br>
<input type="text" name="destzip" value="" maxlength="6" size="6"
tabindex="2"><br>
Weight (lbs.)<br>
<input type="text" name="weight0" value="" size="5" maxlength="5"
tabindex="3"><br>
<input type="hidden" name="shipClass0" value=60>
<input type="hidden" name="weight1" value="">
<input type="hidden" name="shipClass1" value="noClass">
<input type="hidden" name="weight2" value="">
<input type="hidden" name="shipClass2" value="noClass">
<input type="hidden" name="weight3" value="">
<input type="hidden" name="shipClass3" value="noClass">
<input type="hidden" name="weight4" value="">
<input type="hidden" name="shipClass4" value="noClass">
<input type="hidden" name="ltldd" value="S">
<input type="hidden" name="payment" value="P">
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>

As of right now I get nothing for $result...
Thanks,
Michael
Received on 2004-03-08