Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-27-2011, 07:17 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
func_http: a simple helper class for POSTing and GETing with cURL

Stefan recently added support for making cURL requests through a GScript wrapper. This allows you to make both POST and GET requests serverside, without requiring Stefan to enable TSocket on your server (as was previously required for making POST requests).

This class is meant both to help document cURL and to be used to simplify repeated requests. It allows you to use a single function to POST or GET data.

To use the class, all you need to do is join it and call the appropriate function.

Example (GET):
PHP Code:
temp.ip this.get("http://automation.whatismyip.com/n09230945.asp");
echo(
"server IP: " temp.ip); 
I don't see any request to use cURL over requestURL for GET requests, except that cURL is possibly more reliable.

Example (POST):
PHP Code:
// paste to pastebin.graalcenter.org
temp.data = {
  {
"text""This paste was submitted by *an npcserver*."},
  {
"syntax""Markdown"}
};

temp.pasteURL this.post("http://pastebin.graalcenter.org/paste.php"temp.data);
echo(
"paste URL: " temp.pasteURL); 
The data array you pass is made into a query string which is then submitted as POST data. Note that you can send binary data (e.g. a PNG) without base64encoding it. Keys and values are both escaped, so you can use any characters in them you want.

func_http class:
http://pastebin.graalcenter.org/read.php?id=02042935537
__________________

Last edited by cbk1994; 11-27-2011 at 05:41 PM.. Reason: typo
Reply With Quote
  #2  
Old 11-27-2011, 07:22 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
That is pretty sweet.
__________________
Quote:
Reply With Quote
  #3  
Old 11-27-2011, 08:02 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
I'm not interested in Graal/GS2 right now, but I can imagine this will be awesome for scripters. If I'm right, this means that scripters can more easily pass server data to their own web server for things like server stats/player cards?
Reply With Quote
  #4  
Old 11-27-2011, 08:27 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by DustyPorViva View Post
I'm not interested in Graal/GS2 right now, but I can imagine this will be awesome for scripters. If I'm right, this means that scripters can more easily pass server data to their own web server for things like server stats/player cards?
Yes, much more easily.
__________________
Reply With Quote
  #5  
Old 11-27-2011, 02:32 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Making Facebook accessible through Graal, cool
__________________
Reply With Quote
  #6  
Old 11-27-2011, 05:40 PM
0PiX0 0PiX0 is offline
Coder
0PiX0's Avatar
Join Date: Jan 2011
Posts: 130
0PiX0 is a jewel in the rough0PiX0 is a jewel in the rough
Thanks. This is great.
__________________
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 03:32 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.