Web Requests

Send game data to your own server via GET/POST.

Web Requests sends sector data from Guild Battlegrounds to your own server via HTTP request – as GET with URL parameters or as POST with a JSON or form body. What the server does with it (bot, spreadsheet, database) is up to you. For announcements straight into a Discord channel, use Discord Webhooks.

The Web Requests window with the list of profiles
The Web Requests window with the list of profiles

Opening

  • Menu bar: Web Requests icon (see menu bar).
  • In the Guild Battlegrounds window under the gear → Sending tab: as long as there is no profile, it shows “No profile available. Please create one” with an Open button.

The window never opens by itself.

Profiles

A profile describes one request: target, method and content. The Profiles list shows each profile's name, method and target URL. If there are none yet, it says “No profiles yet.”

Button Effect
Send test Sends the profile to the server with sample values.
Edit Opens the profile in the form.
Trash can Deletes the profile immediately, without confirmation.

New profile opens an empty form.

Creating a profile

The form of a POST profile with body template and preview
The form of a POST profile with body template and preview
Field Meaning
Name You pick the profile by this name in Guild Battlegrounds.
Target URL Address of your server. It may contain placeholders, e.g. https://example.com/gbg.php?sector=#name&attrition=#attrition. The values are URL-encoded.
Method GET – values as URL parameters or POST – values in the body.
Body format POST only: JSON (in PHP: php://input) or Form data (in PHP: $_POST).
Body template POST only: the request content with placeholders. Prefilled with all placeholders in the selected format.

When you switch the body format, the helper only replaces the template while it is empty or still identical to the default of the other format.

At the bottom are the buttons Cancel, Preview, Send test and Save. When saving, the helper checks:

  • Name and target URL must be filled in, otherwise: “Please enter a name and a target URL!”
  • The URL must start with https://. http://localhost and http://127.0.0.1 are allowed as well. The browser blocks other http:// targets as mixed content.

Body formats

Placeholders are inserted JSON-safe (quotes and special characters escaped), but without quotes of their own – you put those in the template. The body is sent as plain text, without Content-Type: application/json; in PHP you read it via php://input. Default:

{
	"sector": "#name",
	"battletype": "#battletype",
	"time": #time,
	"attrition": "#attrition",
	"guild": "#guild",
	"vp": "#vp",
	"neighbors": "#neighbors",
	"player": "#player",
	"world": "#world"
}

One line per field in the format key=value. Empty lines and lines without = are skipped. The body is sent as application/x-www-form-urlencoded; in PHP the values end up in $_POST. Default:

sector=#name
battletype=#battletype
time=#time
attrition=#attrition
guild=#guild
vp=#vp
neighbors=#neighbors
player=#player
world=#world

Preview

Preview shows the method, the resolved URL and – for POST – the resolved body with these sample values (Send test uses the same ones):

Placeholder Sample value
#name A1 - Test Province
#battletype 🔴
#time now + 5 minutes (Unix timestamp)
#attrition 42
#guild Test Guild
#vp 96 (+4)
#neighbors Guild A, Guild B
#player your player name
#world your world

If the resulting JSON body is not valid JSON, the preview adds “The body is not valid JSON.” The preview updates when the form opens and on Preview or Send test, not while you type.

No response (fire-and-forget)

Requests are sent without waiting for a response. The helper evaluates neither the response nor errors and always reports “The request was sent (the response is not evaluated).” Custom headers (for example for authentication) cannot be set.

Placeholders

The same placeholders as in the Discord templates apply:

Placeholder Value
#name Name of the sector
#battletype 🔴 for the attack battle type, otherwise 🔵
#time Opening time as a Unix timestamp (seconds)
#attrition Attrition chance of the sector as a number (without %)
#guild Guild that owns the sector
#vp Victory points of the sector, a bonus in brackets, e.g. 96 (+4)
#neighbors Adjacent guilds, comma-separated – without your own guild and without the owner
#player Your player name
#world Your world, e.g. en12

Victory points, neighbors and attrition can still change until the sector opens; the values at the time of the click are sent.

Using it in Guild Battlegrounds

In the Guild Battlegrounds window, open the gear (see window buttons), switch to the Sending tab and pick a profile in the Web Requests section (Please choose = off). Save applies the selection.

After that, the live overview shows a Send via web request button in the list of upcoming sectors for every sector that doesn't belong to your guild. Click rows to select them; above the list you then get Send selected provinces via web request: one request per selected sector, sorted by opening time, with one combined success message.

Unlike Discord Webhooks there is no automatic sending – web requests are only sent on click.

Settings

The window has no gear of its own. Which profile Guild Battlegrounds uses is set in the Guild Battlegrounds settings (see above).

FAQ

My server receives nothing. The helper always shows the success message, even if the request fails. Check the URL in the preview and look at your server's logs. Your server doesn't need CORS headers, because the helper doesn't read the response anyway.

Saving says “Only https:// URLs (or http://localhost) are possible”. The game runs over https, so the browser doesn't allow requests to unencrypted addresses. Use an https address, or http://localhost for testing.

My PHP script doesn't find the JSON values in $_POST. JSON does not end up in $_POST. Read the body via php://input or switch the profile to Form data (in PHP: $_POST).

See also