This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-08-18 15:25:08

jvvg
Scratcher
Registered: 2008-03-26
Posts: 1000+

Squeak POST

I am re-writing the Mod Share Uploader in Insanity, but need a bit of help.

I want to send a POST request to scripts/upload.php with the following POST arguments;
title = filename of project
description = project notes
license = project license (pd, ms, or cc)
filetype = mod chosen (insanity11 in this case
editpass = blank
project = a file upload containing the project

How would I do this?


http://tiny.cc/zwgbewhttp://tiny.cc/e1gbewhttp://tiny.cc/zygbewhttp://tiny.cc/izgbew
Goodbye, Scratch 1.4  sad                                                        Hello Scratch 2.0!  smile

Offline

 

#2 2012-08-18 18:45:57

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Squeak POST

I couldn't find any docs on squeak.org either...

Offline

 

#3 2012-08-18 21:10:06

jvvg
Scratcher
Registered: 2008-03-26
Posts: 1000+

Re: Squeak POST

LS97 wrote:

I couldn't find any docs on squeak.org either...

I saw it on these forums somewhere (I think it involves HTTPSocket), but I can't seem to find it.  hmm


http://tiny.cc/zwgbewhttp://tiny.cc/e1gbewhttp://tiny.cc/zygbewhttp://tiny.cc/izgbew
Goodbye, Scratch 1.4  sad                                                        Hello Scratch 2.0!  smile

Offline

 

#4 2012-08-19 13:52:07

jvvg
Scratcher
Registered: 2008-03-26
Posts: 1000+

Re: Squeak POST

Bump.  sad


http://tiny.cc/zwgbewhttp://tiny.cc/e1gbewhttp://tiny.cc/zygbewhttp://tiny.cc/izgbew
Goodbye, Scratch 1.4  sad                                                        Hello Scratch 2.0!  smile

Offline

 

#5 2012-08-19 16:42:56

XenoK
Scratcher
Registered: 2011-09-08
Posts: 1000+

Re: Squeak POST

I don't know how to do it but I know where to find HTTPSocket, it's under network protocols


Eternity Tasks has launched into Alpha One! http://tasks.eternityincurakai.com/EI%20projects.png

Offline

 

#6 2012-08-19 21:03:39

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: Squeak POST

I coded one for dreamod; let me go find it.   hmm

EDIT:  Ah yes, here we go.

This seems to work!

Code:

|t1 t2 |
t1_ WeakKeyAssociation new value: #('This is a test.').
t1 key: 'test'.
t2 _ #() asOrderedCollection.
t2 add: t1.
^ HTTPSocket httpPostDocument: 'www.blocks.scratchr.org/postPing.php' args: t2

This code assigns the string "This is a test." to the arg "test" and passes the data, as the postPing.php page shows. 

If you want more args, create WeakKeyAssociations.  Each one represents an arg.  Use the "value: (string)" method to give them the arg value and the "key: (string)" method to give them their names.  Add them all to an OrderedCollection using "add: (WeakKeyAssociation)" and call this code at the end:

^ HTTPSocket httpPostDocument: (string with the url) args: (OrderedCollection)

Last edited by Greenatic (2012-08-19 21:14:59)

Offline

 

#7 2012-08-20 05:17:26

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Squeak POST

That's awesome Greenatic, I bookmarked it!
But how can you pass file data if all you can pass are strings? Is there a way to specify encoding/content type?

Offline

 

#8 2012-08-20 12:48:03

jvvg
Scratcher
Registered: 2008-03-26
Posts: 1000+

Re: Squeak POST

Thanks, Greenatic.

How do I send files, though?


http://tiny.cc/zwgbewhttp://tiny.cc/e1gbewhttp://tiny.cc/zygbewhttp://tiny.cc/izgbew
Goodbye, Scratch 1.4  sad                                                        Hello Scratch 2.0!  smile

Offline

 

#9 2012-08-20 13:12:26

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Squeak POST

http://scratch.mit.edu/forums/viewtopic … 3#p1278593

I haven't really tested it so tell me how it works...


http://block.site90.net/scratch.mit/text.php?size=30&text=%20A%20signature!&color=333333

Offline

 

#10 2012-08-20 14:08:51

jvvg
Scratcher
Registered: 2008-03-26
Posts: 1000+

Re: Squeak POST

MathWizz wrote:

http://scratch.mit.edu/forums/viewtopic … 3#p1278593

I haven't really tested it so tell me how it works...

Thanks, I'll try it.


http://tiny.cc/zwgbewhttp://tiny.cc/e1gbewhttp://tiny.cc/zygbewhttp://tiny.cc/izgbew
Goodbye, Scratch 1.4  sad                                                        Hello Scratch 2.0!  smile

Offline

 

#11 2012-08-21 13:13:55

jvvg
Scratcher
Registered: 2008-03-26
Posts: 1000+

Re: Squeak POST

This code appears to work! Thanks!

I tested it out, and it uploads test data fine. Now I just need to port the code.

Last edited by jvvg (2012-08-21 13:16:08)


http://tiny.cc/zwgbewhttp://tiny.cc/e1gbewhttp://tiny.cc/zygbewhttp://tiny.cc/izgbew
Goodbye, Scratch 1.4  sad                                                        Hello Scratch 2.0!  smile

Offline

 

#12 2012-08-21 13:40:38

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Squeak POST

jvvg wrote:

This code appears to work! Thanks!

I tested it out, and it uploads test data fine. Now I just need to port the code.

big_smile


http://block.site90.net/scratch.mit/text.php?size=30&text=%20A%20signature!&color=333333

Offline

 

#13 2012-08-21 13:49:04

jvvg
Scratcher
Registered: 2008-03-26
Posts: 1000+

Re: Squeak POST

MathWizz wrote:

jvvg wrote:

This code appears to work! Thanks!

I tested it out, and it uploads test data fine. Now I just need to port the code.

big_smile

So far, it's going well. If all works, I will have the uploader fully functioning in a minute or two.  smile

Now that the Squeak portion works, I just need to get the PHP portion working.

Last edited by jvvg (2012-08-21 13:49:27)


http://tiny.cc/zwgbewhttp://tiny.cc/e1gbewhttp://tiny.cc/zygbewhttp://tiny.cc/izgbew
Goodbye, Scratch 1.4  sad                                                        Hello Scratch 2.0!  smile

Offline

 

#14 2012-08-21 17:36:51

jvvg
Scratcher
Registered: 2008-03-26
Posts: 1000+

Re: Squeak POST

In this changeset, I added it.


http://tiny.cc/zwgbewhttp://tiny.cc/e1gbewhttp://tiny.cc/zygbewhttp://tiny.cc/izgbew
Goodbye, Scratch 1.4  sad                                                        Hello Scratch 2.0!  smile

Offline

 

Board footer