Sent: Thursday, October 02, 2014 at 3:05 AM From: Mytts Sander.Hansen@gmail.com To: beginners@lists.squeakfoundation.org Subject: [Newbies] I can't find any HTTPSocket examples.
So I'm doing a schoolproject in which we have to modify scratch, which is done using squeak. The problem is the teacher thought it was made in python (Because that's how you add mods) and as such we suddenly have a somewhat rushed assignment in a language we have no experience with.
The problem isn't we really don't have time to learn the smalltalk and the modication is not very heavy, so I originally hoped to just find a few examples of how to do stuff and mostly just modify them to our needs. What I'm trying to achieve is relatively simple, calling a .php file on our server. It doesn't take any arguments and doesn't return anything, so I simply just need the server to realize the script is getting called.
I originally wanted to do it using HTTPClient, but my squeak doesn't seem to have this library. I found HTTPSocket however and it seemed to be able to do the job just fine, except I have no idea how to use the class. Everything I try I just get a different error and I'm not sure where to go from here. So any example or just help on how to use the instance/class would be highly appreciated. An attempt I have tried is this one:
CallingPHP "Used to upload the game"
| |
HTTPSocket httpGet: 'http://shgamecrew.dk'.
It seems like HttPSocket doesn't need to be instantiated from what I've gathered, so I thought this would be enough, but alas it seems not. I get a PrimitiveFailed error (Which I have also no idea what means).
Which version of Squeak are you using on what platform. I pasted your example into a Workspace in Squeak4.5 latest update: #13663 on Microsoft Windows [Version 6.1.7601] and inspected it. An instance of #RWBinaryOrTextStream was returned. No errors. What is the test of the errors you are getting?
From your description of you goal, it sounds to me like you would be interested in using #OSProcess.
I recently wrote a method to create a complex script file on my computer and then use #OSProcess to execute it.
You might want to use the #HTTPSocket if you want to invoke your program as a cgi script. Depends on your requirements. You example is just opening a web page.
Personally, I don't see either option as a solution to rushed assignment in a language in which you have no experience.
jrm