Punkland
English
English
  • PUNKLAND
    • Introduction to Punkland
    • 🔔Update History
      • Studio
      • APP
      • Server
  • Punkland Studio
    • 📖Getting Started
      • How to Download Punkland Studio
      • Checking Version and Updates
      • New Project
      • Map Making
        • Add Map
        • Sub Map Creation
        • Edit Map
      • Studio Interface
        • [File] Tab
        • [Edit] Tab
        • [View] Tab
        • [Game] Tab
        • [Tool] Tab
      • Test Play
      • Publish Game
    • 💻Basic Guide
      • Database
      • MP3 to OGG Converter
      • Translation Export
        • Translation Import
      • Script
      • Resource Market
      • Data Export
        • Data Import
      • Help
      • Project Management
      • Text Commands
      • GM Commands
      • Stats
      • Damage Formula
      • Item Formula
      • QnA
    • 👑Advanced Guide
      • Resource Manager
      • Sprite Manager
      • Layout Manager
      • Top Menu Manager
      • Event page Manager
      • Spine
    • Script Tutorial
      • Use Script
      • Script Docs
      • Server Script
        • ScriptClan
        • ScriptColor
      • Client Script
      • Sample Script
        • UI
        • Monster AI
        • Pet AI
        • Particle
    • Web3 Tutorial
      • Minting and Connection NFT
      • Connectiong ERC-20 Token
    • Effective Punkland
      • Communicating with the Server
      • RunLater
      • HTTP Requests
  • Official Link
    • Punkland Studio Download
    • Website
    • Discord
    • Korea community
Powered by GitBook
On this page
  • Sending a GET Request
  • Sending a POST Request
  • Receiving Data on the Web Server
  1. Punkland Studio
  2. Effective Punkland

HTTP Requests

Using Lua scripts, you can send HTTP requests as shown below.

Sending a GET Request

Server.HttpGet(url, callback)

Example)

-- Send a GET request to http://naver.com and receive data in res
Server.HttpGet('http://naver.com', function(res)
  print(res) -- Prints the returned text from the webpage
end)

Sending a POST Request

Server.HttpPost(url, data, callback) Example)

-- Create a table named t and insert the POST request data
t = {}
t.id = 1234
t.name = "Hello"

-- Send a request to http://naver.com and receive the data in res
Server.HttpGet('http://naver.com', t, function(res)
  print(res) -- The returned text from the webpage is printed.
end)

Receiving Data on the Web Server

When receiving a request via POST, you can print the data as shown below. You can store this data in a database like MySQL for long-term preservation.

<?php
echo $_POST["id"];
echo $_POST["name"];

echo "sucess!";
?>

This code is used to verify that the data sent by Server.HttpGet has successfully reached the web server. In the server script example above, the print(res) statement outputs "1234Hellosuccess!".

PreviousRunLater

Last updated 5 months ago