cURL / Mailing Lists / curl-library / Single Mail


Re: asynchronous posting to a webpage with cURL

From: Brian Dessent <>
Date: Sat, 25 Aug 2007 20:49:30 -0700

Znigniew Widomski wrote:

> I'm using the cURL library built in with php 5. I'm trying to use curl
> to POST to a website that uses ajax an asynchronous posting to
> actually "post" things. I'm just completely and utterly confused when
> you mix words like asynchronous, ajax, and curl together. I understand
> how to post querystrings with curl, this is quite simple to me.
> Asynchronously posting a series of posts to 1 website I am lost...
> Could someone help un confuse me on this... or simply expand if
> asynchronous posting via ajax that a website may inhibit, if this
> limits me in any way with cURL and if so how??

Don't get caught up too much on the asynchronous part. This just means
that the request is initiated in the browser in the background, at some
point after the page has completed loading, without causing a new page
to load. But from the standpoint of HTTP, it is no different than any
other GET or POST. And curl is not a browser at all, it is simply a way
to initiate one or more GET or POSTs, so the notion of "inside a page"
or "after the page has loaded" doesn't really apply at all.

You do the same you do with any other use of curl -- figure out the
location of the GET/POST and the various parameters, and away you go.
You'll have to use e.g. Firebug or LiveHTTPHeaders or Wireshark most
likely because the location and parameters won't be obvious just from
inspection, so you'll need to observe what the scripting does and then
replicate that.

What you may run into though is that the result of this request is some
kind of abstract data -- XML, JSON, whatever. The code to take that
data and cause it to modify the appearance of the page is part of the
scripting that runs in the browser, and that is completely out of the
domain of curl, so if you are expecting HTML you may be disappointed.

Received on 2007-08-26