创建对细分中玩家执行操作的任务
Create an ActionsOnPlayersInSegment task, which iterates through all players in a segment to execute action.
Error codes
This operation may return the following PlayFab errors:
| Error | Code |
|---|---|
| CatalogBadRequest | 4013 |
| CloudScriptAzureFunctionsArgumentSizeExceeded | 1471 |
| InvalidJSONContent | 1200 |
| InvalidParams | 1000 |
| InvalidScheduledTaskName | 1256 |
| InvalidTaskSchedule | 1257 |
| InvalidVirtualCurrencyCode | 1236 |
| OverLimit | 1214 |
| PushNotEnabledForAccount | 1094 |
| PushNotificationTemplateInvalidSyntax | 1419 |
| PushNotificationTemplateNotFound | 1417 |
| ScheduledTaskCreateConflict | 1255 |
| ScheduledTaskNameConflict | 1254 |
| StatisticNotFound | 1195 |
curl --request POST \
--url https://{titleId}.playfabapi.com/Admin/CreateActionsOnPlayersInSegmentTask \
--header 'Content-Type: application/json' \
--header 'X-SecretKey: <api-key>' \
--data '
{
"Name": "PushNotificationVIP_Halloween",
"Description": "Send push notification to VIP players about Halloween event",
"Parameter": {
"SegmentId": "274828AF93F13472",
"Actions": [
{
"GrantItemContent": {
"CatalogVersion": "foo",
"ItemId": "bar",
"ItemQuantity": 1
}
}
]
}
}
'import requests
url = "https://{titleId}.playfabapi.com/Admin/CreateActionsOnPlayersInSegmentTask"
payload = {
"Name": "PushNotificationVIP_Halloween",
"Description": "Send push notification to VIP players about Halloween event",
"Parameter": {
"SegmentId": "274828AF93F13472",
"Actions": [{ "GrantItemContent": {
"CatalogVersion": "foo",
"ItemId": "bar",
"ItemQuantity": 1
} }]
}
}
headers = {
"X-SecretKey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-SecretKey': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
Name: 'PushNotificationVIP_Halloween',
Description: 'Send push notification to VIP players about Halloween event',
Parameter: {
SegmentId: '274828AF93F13472',
Actions: [{GrantItemContent: {CatalogVersion: 'foo', ItemId: 'bar', ItemQuantity: 1}}]
}
})
};
fetch('https://{titleId}.playfabapi.com/Admin/CreateActionsOnPlayersInSegmentTask', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{titleId}.playfabapi.com/Admin/CreateActionsOnPlayersInSegmentTask",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'Name' => 'PushNotificationVIP_Halloween',
'Description' => 'Send push notification to VIP players about Halloween event',
'Parameter' => [
'SegmentId' => '274828AF93F13472',
'Actions' => [
[
'GrantItemContent' => [
'CatalogVersion' => 'foo',
'ItemId' => 'bar',
'ItemQuantity' => 1
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-SecretKey: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{titleId}.playfabapi.com/Admin/CreateActionsOnPlayersInSegmentTask"
payload := strings.NewReader("{\n \"Name\": \"PushNotificationVIP_Halloween\",\n \"Description\": \"Send push notification to VIP players about Halloween event\",\n \"Parameter\": {\n \"SegmentId\": \"274828AF93F13472\",\n \"Actions\": [\n {\n \"GrantItemContent\": {\n \"CatalogVersion\": \"foo\",\n \"ItemId\": \"bar\",\n \"ItemQuantity\": 1\n }\n }\n ]\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-SecretKey", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{titleId}.playfabapi.com/Admin/CreateActionsOnPlayersInSegmentTask")
.header("X-SecretKey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"Name\": \"PushNotificationVIP_Halloween\",\n \"Description\": \"Send push notification to VIP players about Halloween event\",\n \"Parameter\": {\n \"SegmentId\": \"274828AF93F13472\",\n \"Actions\": [\n {\n \"GrantItemContent\": {\n \"CatalogVersion\": \"foo\",\n \"ItemId\": \"bar\",\n \"ItemQuantity\": 1\n }\n }\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{titleId}.playfabapi.com/Admin/CreateActionsOnPlayersInSegmentTask")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-SecretKey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"Name\": \"PushNotificationVIP_Halloween\",\n \"Description\": \"Send push notification to VIP players about Halloween event\",\n \"Parameter\": {\n \"SegmentId\": \"274828AF93F13472\",\n \"Actions\": [\n {\n \"GrantItemContent\": {\n \"CatalogVersion\": \"foo\",\n \"ItemId\": \"bar\",\n \"ItemQuantity\": 1\n }\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"code": 200,
"status": "OK",
"data": {
"TaskId": "644FA3A39C9714BC"
}
}{
"code": 123,
"errorCode": 123,
"status": "<string>",
"error": "<string>",
"errorMessage": "<string>",
"errorDetails": {}
}授权
This API requires a title secret key, available to title admins, from PlayFab Game Manager.
请求体
Task name is unique within a title. Using a task name that's already taken will cause a name conflict error. Too many create-task requests within a short time will cause a create conflict error.
Task name is unique within a title. Using a task name that's already taken will cause a name conflict error. Too many create-task requests within a short time will cause a create conflict error.
Whether the schedule is active. Inactive schedule will not trigger task execution.
Name of the task. This is a unique identifier for tasks in the title.
Task details related to segment and action
Show child attributes
Show child attributes
{
"SegmentId": "502FD30E8C78F826",
"Actions": [
{
"GrantItemContent": {
"CatalogVersion": "foo",
"ItemId": "bar",
"ItemQuantity": 1
}
}
]
}
The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.).
Description the task
Cron expression for the run schedule of the task. The expression should be in UTC.
此页面对您有帮助吗?
curl --request POST \
--url https://{titleId}.playfabapi.com/Admin/CreateActionsOnPlayersInSegmentTask \
--header 'Content-Type: application/json' \
--header 'X-SecretKey: <api-key>' \
--data '
{
"Name": "PushNotificationVIP_Halloween",
"Description": "Send push notification to VIP players about Halloween event",
"Parameter": {
"SegmentId": "274828AF93F13472",
"Actions": [
{
"GrantItemContent": {
"CatalogVersion": "foo",
"ItemId": "bar",
"ItemQuantity": 1
}
}
]
}
}
'import requests
url = "https://{titleId}.playfabapi.com/Admin/CreateActionsOnPlayersInSegmentTask"
payload = {
"Name": "PushNotificationVIP_Halloween",
"Description": "Send push notification to VIP players about Halloween event",
"Parameter": {
"SegmentId": "274828AF93F13472",
"Actions": [{ "GrantItemContent": {
"CatalogVersion": "foo",
"ItemId": "bar",
"ItemQuantity": 1
} }]
}
}
headers = {
"X-SecretKey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-SecretKey': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
Name: 'PushNotificationVIP_Halloween',
Description: 'Send push notification to VIP players about Halloween event',
Parameter: {
SegmentId: '274828AF93F13472',
Actions: [{GrantItemContent: {CatalogVersion: 'foo', ItemId: 'bar', ItemQuantity: 1}}]
}
})
};
fetch('https://{titleId}.playfabapi.com/Admin/CreateActionsOnPlayersInSegmentTask', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{titleId}.playfabapi.com/Admin/CreateActionsOnPlayersInSegmentTask",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'Name' => 'PushNotificationVIP_Halloween',
'Description' => 'Send push notification to VIP players about Halloween event',
'Parameter' => [
'SegmentId' => '274828AF93F13472',
'Actions' => [
[
'GrantItemContent' => [
'CatalogVersion' => 'foo',
'ItemId' => 'bar',
'ItemQuantity' => 1
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-SecretKey: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{titleId}.playfabapi.com/Admin/CreateActionsOnPlayersInSegmentTask"
payload := strings.NewReader("{\n \"Name\": \"PushNotificationVIP_Halloween\",\n \"Description\": \"Send push notification to VIP players about Halloween event\",\n \"Parameter\": {\n \"SegmentId\": \"274828AF93F13472\",\n \"Actions\": [\n {\n \"GrantItemContent\": {\n \"CatalogVersion\": \"foo\",\n \"ItemId\": \"bar\",\n \"ItemQuantity\": 1\n }\n }\n ]\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-SecretKey", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{titleId}.playfabapi.com/Admin/CreateActionsOnPlayersInSegmentTask")
.header("X-SecretKey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"Name\": \"PushNotificationVIP_Halloween\",\n \"Description\": \"Send push notification to VIP players about Halloween event\",\n \"Parameter\": {\n \"SegmentId\": \"274828AF93F13472\",\n \"Actions\": [\n {\n \"GrantItemContent\": {\n \"CatalogVersion\": \"foo\",\n \"ItemId\": \"bar\",\n \"ItemQuantity\": 1\n }\n }\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{titleId}.playfabapi.com/Admin/CreateActionsOnPlayersInSegmentTask")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-SecretKey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"Name\": \"PushNotificationVIP_Halloween\",\n \"Description\": \"Send push notification to VIP players about Halloween event\",\n \"Parameter\": {\n \"SegmentId\": \"274828AF93F13472\",\n \"Actions\": [\n {\n \"GrantItemContent\": {\n \"CatalogVersion\": \"foo\",\n \"ItemId\": \"bar\",\n \"ItemQuantity\": 1\n }\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"code": 200,
"status": "OK",
"data": {
"TaskId": "644FA3A39C9714BC"
}
}{
"code": 123,
"errorCode": 123,
"status": "<string>",
"error": "<string>",
"errorMessage": "<string>",
"errorDetails": {}
}