Mechanize->Post

144 views
Skip to first unread message

ddunleavy2

unread,
Jun 20, 2012, 3:31:07 PM6/20/12
to www-mecha...@googlegroups.com
I'm trying to call $mech->post and posting a filename that my previous page supplied to me.

This is what I'm trying to recreate using mechanize.
/*******    Fiddler Output **********/
POST https://zipcodedownload.com/customer/DownloadProdcut HTTP/1.1
Host: zipcodedownload.com
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:13.0) Gecko/20100101 Firefox/13.0.1
Accept: */*
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With: XMLHttpRequest
Referer: https://zipcodedownload.com/Account
Content-Length: 117
Cookie: __utma=229236631.568973291.1315837689.1340122206.1340129864.17; __utmz=229236631.1319476276.4.3.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=zipcodedownload.com; Nop.customer=452ca35c-69c3-4f7c-8692-9d30fcedd480; NOPCOMMERCE.AUTH=EDE502A471B6DC7B016B392FB36330FA28B3ABD510C53A71BAA359AB0CCB420F47E65A3D7FBF288A4A19FB54552E6B33109B1A84A9C86291093021EA1123D262EADDCD722636959B0D7A6B85E5A2D3078D9AEC778CC46DE831BF625B13DBFA46145167B4054A25C8FCBC7E40803846BE1A7FB36688DF39E4A262B2016C5712DB4C1052DA8E57495AE7EBABC538E2B722159FF8D06F5216AD244AA4541E6B97466D0E605EB00702D48E455CDD318D4BAF17EC1E82F9C2F212BB1A6667ABA0C54FCD5386AC785D9856001F9CFA93DC30EB; __utmb=229236631.2.10.1340129864; __utmc=229236631
Pragma: no-cache
Cache-Control: no-cache

filename=WstR8%252baW3oKaUe69z3dsh%252f2MdaofcaimgKF5jkLsglXb25Hu4oNg8WKsht35ARX0BphaEq%252bN7NHMwomQra8VJg%253d%253d

To that end this is my command

$amazon_parameters = $mech->post("https://zipcodedownload.com/customer/DownloadProdcut",['filename'=>$foundit,'content_type'=>'application/x-www-form-urlencoded']); where $foundit is the filename listed above.  

Instead of getting this good page:

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: application/json; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNetMvc-Version: 3.0
X-AspNet-Version: 4.0.30319
Set-Cookie: Nop.customer=452ca35c-69c3-4f7c-8692-9d30fcedd480; expires=Wed, 19-Jun-2013 18:18:03 GMT; path=/
X-Powered-By: ASP.NET
Date: Tue, 19 Jun 2012 18:18:03 GMT
Content-Length: 192

{"Status":true,"Url":"http://zipcodedownload.s3.amazonaws.com/jun2012_z5c6combined_csv.zip?AWSAccessKeyId=AKIAIDHXD5XPP2XFX6WA&Expires=1340129914&Signature=jc7OMAiQ9CBc4CEsM%2FvmLEQF%2B2Q%3D"}

I get an error page.



Any ideas on why my POST isn't working.    I've looked all over the Internet -- Please dont send me to the CPAN::Mechanize site in the cookbook section.  ;)

Thanks very much.






Reply all
Reply to author
Forward
0 new messages