CallAPIForSession
This is a generic method for calling client API services with a player session context.
Method Parameters
Parameter | Description |
---|---|
session | The sessionId to make the call in the context of |
service | The name of the service |
operation | The name of the operation to call on the service |
serviceData | The parameters to send to the operation |
Note - the API Explorer is a great reference to determine the JSON format of the parameters.
Usage
http://localhost:3000
- C#
- C++
- Objective-C
- Java
- JavaScript
- Dart
- Cloud Code
- Raw
// Cloud Code only. To view example, switch to the Cloud Code tab
// Cloud Code only. To view example, switch to the Cloud Code tab
// Cloud Code only. To view example, switch to the Cloud Code tab
// Cloud Code only. To view example, switch to the Cloud Code tab
// Cloud Code only. To view example, switch to the Cloud Code tab
// Cloud Code only. To view example, switch to the Cloud Code tab
// Construct the parameters
var serviceData = {};
serviceData.toId = "aaaa-bbbb-cccc-dddd";
serviceData.eventType = "hearts";
serviceData.eventData = {};
serviceData.eventData.numHearts = 3;
// Retrieve a session for the specified profile
var session = bridge.getSessionForProfile("eeee-ffff-gggg-hhh");
// Call the API in the context of the retrieved session
var res = bridge.callAPIForSession(session, "event", "SEND", serviceData);
// Construct the parameters
var serviceData = {};
serviceData.toId = "aaaa-bbbb-cccc-dddd";
serviceData.eventType = "hearts";
serviceData.eventData = {};
serviceData.eventData.numHearts = 3;
// Retrieve a session for the specified profile
var session = bridge.getSessionForProfile("eeee-ffff-gggg-hhh");
// Call the API in the context of the retrieved session
var res = bridge.callAPIForSession(session, "event", "SEND", serviceData);