The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 17, 2019, 06:23:59 PM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: cURL with XMLHttpRequest  (Read 4797 times)
cdc
Expert
****
Offline Offline

Posts: 105


View Profile
« on: May 12, 2007, 07:58:15 AM »

As usual, I'm trying to post a form to a site, but it does it through AJAX. Everything I've tried so far does not work.  Cry

Here's the pieces of the header that look suspect to me when I POST successfully from my browser:

Quote
Accept: text/javascript, text/html, application/xml, text/xml, */*
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: close
X-Requested-With: XMLHttpRequest
X-Prototype-Version: 1.5.0_rc0
Content-Type: application/x-www-form-urlencoded

When I try to do it my "traditional" way it just comes back and says that I need a JavaScript enabled browser to submit the form.

Any idea how to get PHP/cURL to handle this?
Logged

Will code for food.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #1 on: May 12, 2007, 08:50:10 AM »

As usual, I'm trying to post a form to a site, but it does it through AJAX. Everything I've tried so far does not work.  Cry
First off C, I need to question your intentions here: you don't POST a form via ajax - you can send a ajax request with a post-type message, but not post a form... is this what you mean?

Second - are you using the AjaxRequestor class in the javascript repository or are you just doing this by hand?

Here's the pieces of the header that look suspect to me when I POST successfully from my browser:

Accept: text/javascript, text/html, application/xml, text/xml, */*
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: close
X-Requested-With: XMLHttpRequest
X-Prototype-Version: 1.5.0_rc0
Content-Type: application/x-www-form-urlencoded
Doesn't look bad to me except that there's no content or content size after those headers...


Here's the pieces of the header that look When I try to do it my "traditional" way it just comes back and says that I need a JavaScript enabled browser to submit the form.
Who "says" that? Is it IE/your browser giving that message? Is PHP actually creating that message and sending it back? Need considerably more snippets and such to make heads or tails of this...

/p
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
cdc
Expert
****
Offline Offline

Posts: 105


View Profile
« Reply #2 on: May 12, 2007, 09:41:13 AM »

Sorry for the confusion.

I'm trying to automate submitting a form on a third party site. The third party site uses (from what I can tell) AJAX to haul my data back to the server when I push the submit button. I think that's what

X-Requested-With: XMLHttpRequest

is telling me anyway.

When I look at what cURL is returning, it's a message saying, "Sorry, you need JavaScript enabled to submit forms." This is the third party site telling me this. I get the same message if I copy the URL and post fields from the headers and paste them into my address bar.

Hopefully this makes more sense...
Logged

Will code for food.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #3 on: May 12, 2007, 11:18:20 AM »

PMing you now...
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
thedarkness
Lifer
*****
Offline Offline

Posts: 585



View Profile
« Reply #4 on: May 13, 2007, 02:30:58 AM »

I'd say there are two possibilities here if they are using AJAX for their form "submission". One is to dismantel their XMLHttpRequest and try and post this directly from your program, this will only work if they are not restricting access to their server. Further explanation, lets say that they are posting using GET as follows;

http://their.server.com?name=fred&eaddress=fred@dag.com&dollars=1000

Theirs nothing stopping you technically from hitting that link from anywhere unless they have secured it in some fashion (prolly fairly likely, although.....) Same goes if it's using POST although a level of magnitude more difficult.

If you cannot use the first method then you need to look at some form of browser automation such as using MS's webbrowser object or shdocvw (both automating IE). Easy enough to do if you know how, non-trivial otherwise.

If you want some tips on option two, PM me and I'll give you any help I can.

Cheers,
td
Logged

"I want to be the guy my dog thinks I am."
 - Unknown
cdc
Expert
****
Offline Offline

Posts: 105


View Profile
« Reply #5 on: May 13, 2007, 03:18:35 PM »

Yeah, it looks like I'd have to go with option 2 because if I just post the variables the server comes back and says that I need a JS enabled browser, so something else is going on with this.

It's not worth going the extra mile for. There are plenty of other sites to spam fish in the sea.
Logged

Will code for food.
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!