This article relates to the game "Dota 2". Click here for more information.
This article relates to the SDK/Workshop Tools for "Dota 2 Workshop Tools". Click here for more information.
This article's documentation is for Source 2. Click here for more information.

Dota 2 Workshop Tools/Scripting/Using CreateHTTPRequest: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(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...")
 
(Added top icons)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
{{Dota 2Tools topicons}}
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.
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.


Line 10: Line 11:
end )
end )
</syntaxhighlight >
</syntaxhighlight >
{{shortpagetitle}}
[[Category: Dota 2 Workshop Tools]]

Latest revision as of 18:43, 15 May 2020

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 )