Dota 2 Workshop Tools/Scripting/Using CreateHTTPRequest

From Valve Developer Community
< Dota 2 Workshop Tools‎ | Scripting
Revision as of 11:03, 25 June 2015 by JeffHill (talk | contribs) (Created page with "Here's an example of using CreateHTTPRequest to fetch a URL. CreateHTTPRequest returns a CScriptHTTPRequest object the most important function of which is Send( completionCall...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Here's an example of using CreateHTTPRequest to fetch a URL. CreateHTTPRequest returns a CScriptHTTPRequest object the most important function of which is Send( completionCallback ). This example creates the request and immediately sends it with a completion routine that simply prints the resulting data.

CreateHTTPRequest( "GET", "http://www.google.com" ):Send( function( result )
	print( "GET response:\n" )
	for k,v in pairs( result ) do
		print( string.format( "%s : %s\n", k, v ) )
	end
	print( "Done." )
end )