-
Call webservice
Hi,
I am creating a game which needs to call a webservice. The webservice is REST+HTTP based and returns either JSON or XML (based on the Accept header).
Security is either Basic Authorization (using the Authorization HTTP header) or two-legged OAuth.
How can I call such a webservice from my game?
Putting it simple I just need to download a file (a .xml file) from a webserver using HTTP while being able to modify the HTTP headers.
-
Re: Call webservice
Using the get object you should be able to achieve the result you want.
You can pass a url to the get object and display the results in rich edit box or edit box. whichever you prefer,
You could also use the download object but i find that the get object works a bit better.
Unfortunately i had to develop another solution for use in my Application as my companies proxy server blocked access using both these objects. the result was the use of a vbscript which was compiled on the fly.
it's quite easy to do especially if you only have a few variables. if you want me to knock an example together i'll need all the info you want to pass to the server.
-
Re: Call webservice
Get object won't do any auth/header modification.
-
Re: Call webservice
in that case the vbscript option is probably the better
-
Re: Call webservice
It would be great if you could paste your vbscript lembi2001, and write a short description on how to use it :)
-
Re: Call webservice
I can do that no problem but I have a few different ones. Each one performs a different operation dependant on what the desired result is. That is the reason I was asking for the variables you pass to the server.
I have 3 scripts.
One downloads an image from a website, the other two download a full web page and save them as html. I may be able to modify one of the page downloaders but i need to know what the response looks like and also the request.
I am not being awkward honestly, i just want to make sure that i give you the correct script.
-
Re: Call webservice
It won't be a problem for me to write the VBScript myself, it would however be very helpful if you could give me a hint on how to use this script inside MMF
-
Re: Call webservice
You have to tell him what you want the pass to the server.
-
Re: Call webservice
I can create the VBScript myself, so it isn't important how the communication with the server is handled.
I would however really appreciate it, if someone could explain how to call a VBScript from a MMF game.
Thanks in advance,
Uldall
-
Re: Call webservice
Sorry for the delayed response. Completely forgot about this thread.
If you haven't soved it already, this is how i did it.
Copy wscript.exe (usually C:\windows\system32) to your apps folder (this is so that it can always be found)
Have a template vbscript in there too. For the variables in the script replace them with something you can identify.
For example in the Library Application i used these scripts in my book cover downloader had the variable <<ISBN>> in the web address.
At the start of the frame i loaded my template vbscript into a rich edit box. when the search button was clicked the following was done:
A search was done to find <<ISBN>> in the script template. this was then selected. I replaced the selection with the actual ISBN number i was searching for i then saved this as a vbscript of a different filename.
using the event File <<scriptname>>.vbs exists and Only one action.... i then triggered the execution of the vbsctipt using the following syntax:
Execute External Program
Program Name - Appdir$+"wscript.exe"
Command Line - " <<scriptname>>.vbs"
Application behaviour - "wait"
You need to select wait if your app requires the results of your vbscript to function correctly.
Once you have the results you can delete <<scriptname.vbs>> as part of your app
If this is unclear let me know and i will mock something up for you.