The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 20, 2019, 11:38:16 PM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: multipart/form-data post with curl  (Read 24529 times)
crypt
Rookie
**
Offline Offline

Posts: 12


View Profile
« on: May 13, 2007, 08:49:32 PM »

Here is one thing I haven't been able to figure out. Luckily every time I've run into it, I've found a workaround. However, I have not been able to figure out how to use curl to make a multipart post. I have found a link on the curl homepage that explains how to upload a file with a multipart form (which is actually the purpose of the multipart form). That method requires you to have a file, and well I don't intend to upload a file. All I am trying to do is post comment spam on a few blogs. Sorry, don't have any links handy, because I haven't run into it for a while... Any ideas?

Here is the article on how to upload a file: http://curl.netmirror.org/libcurl/php/examples/multipartpost.html

Thanks

PS: I moved this to the correct forum
Logged

No links in signatures please
cdc
Expert
****
Offline Offline

Posts: 105


View Profile
« Reply #1 on: May 13, 2007, 11:38:00 PM »

It's actually pretty simple. Instead of passing a string like this as your parameter:

"variable1=value1&variable2=value2"

You just put them in an associative array:

$parameters = array("variable1" => "value1", "variable2" => "value2");

Nothing else changes.
Logged

Will code for food.
Bompa
Administrator
Lifer
*****
Offline Offline

Posts: 564


Where does this show?


View Profile
« Reply #2 on: May 14, 2007, 03:44:25 AM »

Here is one thing I haven't been able to figure out. Luckily every time I've run into it, I've found a workaround. However, I have not been able to figure out how to use curl to make a multipart post.

I've seen this same question somewhere a few months ago.  Was that you crypt?

Anyways, unless I am completely misunderstanding you, you want to post some info
like username, then you have to click Continue, and then you get another page with
another form that asks for more info, right?

Post the info for the first page.
The server you are posting to then sends back the next page and your code should
parse it for the variable that it wants, (while testing i have the returned-page printed
to my console and printed to a file so I can look it over).

So, you script, still running, not stopping, parses the second page for variables and
posts them to the correct URL.

The same process could go on and on, it's still the same logic in the code.

The thing is, when finished and working, your script can not stop in between the
form pages unless it were to save previous variables to disk then read them in when
it starts up again, which is nuts.

Bompa

Logged

"The most beautiful and profound emotion we can experience is the sensation of the mystical..." - Albert Einstein
crypt
Rookie
**
Offline Offline

Posts: 12


View Profile
« Reply #3 on: May 14, 2007, 12:58:07 PM »

Actually cdc mentioned my work around, I guess that's just the proper way to do it. Didn't think it would work all the time. 

thanks
Logged

No links in signatures please
crypt
Rookie
**
Offline Offline

Posts: 12


View Profile
« Reply #4 on: May 16, 2007, 06:19:16 PM »

I see what you're saying now Bompa.. Nope, not the same thing I'm dealing with.. That's the oldskool way to pass variables using hidden inputs. I've run into this one recently too, but it was easy enough to figure out.
Logged

No links in signatures please
Bompa
Administrator
Lifer
*****
Offline Offline

Posts: 564


Where does this show?


View Profile
« Reply #5 on: May 16, 2007, 07:03:51 PM »

I guess I don't know what ppl mean when they say "multipart" form.

oh well.
Logged

"The most beautiful and profound emotion we can experience is the sensation of the mystical..." - Albert Einstein
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #6 on: May 17, 2007, 08:58:16 AM »

the short version is multipart form encoding is used when you are using forms to upload non-text (files) through a webpage.

so like the image uploader on imageshack.us is a multipart form.
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
Bompa
Administrator
Lifer
*****
Offline Offline

Posts: 564


Where does this show?


View Profile
« Reply #7 on: May 18, 2007, 05:46:38 AM »

the short version is multipart form encoding is used when you are using forms to upload non-text (files) through a webpage.

so like the image uploader on imageshack.us is a multipart form.


Ohhhhh.  I have not yet had the need to upload non-text files.

I thought they meant multi-page forms, duh.
Logged

"The most beautiful and profound emotion we can experience is the sensation of the mystical..." - Albert Einstein
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #8 on: May 18, 2007, 08:55:25 AM »

yea, its actually surprising how, Un-straightforward it is to do as well.
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
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!