PHP 5 has reached end of support and will be
deprecated
on January 31, 2026. After deprecation, you won't be able to deploy PHP 5
applications, even if your organization previously used an organization policy to
re-enable deployments of legacy runtimes. Your existing PHP
5 applications will continue to run and receive traffic after their
deprecation date. We recommend that
you
migrate to the latest supported version of PHP.
\google\appengine\api\taskqueue\PushTask
Stay organized with collections
Save and categorize content based on your preferences.
FINAL
A PushTask encapsulates a unit of work that an application places onto a
Push Queue for asynchronous execution. The queue executes that work by
sending the task back to the application in the form of an HTTP request to
one of the application's handlers.
This class is immutable.
Constants
MAX_DELAY_SECONDS
A task may be scheduled up to 30 days into the future.
MAX_NAME_LENGTH
MAX_TASK_SIZE_BYTES
MAX_URL_LENGTH
NAME_PATTERN
Methods
__construct
__construct(string $url_path, array $query_data = array(), array $options = array())
Construct a PushTask.
Parameters
Name |
Description |
$url_path
|
string
The path of the URL handler for this task relative
to your application's root directory. |
$query_data
|
array
The data carried by task, typically in the form of
a set of key value pairs. This data will be encoded using
http_build_query() and will be either:
- Added to the payload of the HTTP request if the task's method is POST
or PUT.
- Added to the URL if the task's method is GET, HEAD, or DELETE.
|
$options
|
array
Additional options for the task. Valid options are:
- 'method': string One of 'POST', 'GET', 'HEAD', 'PUT', 'DELETE'.
Default value: 'POST'.
- 'name': string Name of the task. Defaults to '' meaning the service
will generate a unique task name.
- 'delay_seconds': float The minimum time to wait before executing the
task. Default: zero.
- 'header': string Additional headers to be sent when the task
executes. Note: The 'Content-Type' header cannot be specified.
|
Throws
\google\appengine\api\taskqueue\InvalidArgumentException
if
- A supplied argument is not the correct type.
- Any of the specified options are invalid.
- The header 'content-type' is specified.
- Any supplied headers are not of the format 'key:value'.
getUrl
getUrl() : string
Return the task's URL. This will be the task's URL path, plus any query
parameters if the task's method is GET, HEAD, or DELETE.
Returns
string
The task's URL path.
getQueryData
getQueryData() : array
Return the task's query data.
Returns
array
The task's query data.
getName
getName() : string
Return the task's name if it was explicitly named.
Returns
string
The task's name if it was explicity named, or empty string
if it will be given a uniquely generated name in the queue.
getDelaySeconds
getDelaySeconds() : float
Return the task's execution delay, in seconds.
Returns
float
The task's execution delay in seconds.
getMethod
getMethod() : string
Return the task's HTTP method.
Returns
string
The task's HTTP method: 'DELETE', 'GET', 'HEAD',
'POST', or 'PUT'.
add
add( $queue_name = 'default') : string
Adds the task to a queue.
Parameters
Name |
Description |
$queue_name
|
|
Throws
\google\appengine\api\taskqueue\TaskAlreadyExistsException
if a task of the same name already
exists in the queue.
\google\appengine\api\taskqueue\TaskQueueException
if there was a problem using the service.
Returns
string
The name of the task.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-06-16 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-06-16 UTC."],[[["\u003cp\u003eA PushTask is a unit of work placed on a Push Queue for asynchronous execution, which is then sent back to the application as an HTTP request.\u003c/p\u003e\n"],["\u003cp\u003ePushTasks are immutable, meaning they cannot be changed once created.\u003c/p\u003e\n"],["\u003cp\u003eA PushTask can be scheduled for execution up to 30 days in the future.\u003c/p\u003e\n"],["\u003cp\u003eWhen creating a PushTask, you can define its URL path, query data, HTTP method (POST, GET, HEAD, PUT, DELETE), name, and execution delay.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eadd\u003c/code\u003e method is used to add a PushTask to a specified queue, and it returns the name of the task.\u003c/p\u003e\n"]]],[],null,["# \\google\\appengine\\api\\taskqueue\\PushTask\n\nFINAL\n\nA PushTask encapsulates a unit of work that an application places onto a\nPush Queue for asynchronous execution. The queue executes that work by\nsending the task back to the application in the form of an HTTP request to\none of the application's handlers.\n\nThis class is immutable.\n\nConstants\n---------\n\n### MAX_DELAY_SECONDS\n\nA task may be scheduled up to 30 days into the future.\n\n### MAX_NAME_LENGTH\n\n### MAX_TASK_SIZE_BYTES\n\n### MAX_URL_LENGTH\n\n### NAME_PATTERN\n\nMethods\n-------\n\n### __construct\n\n`__construct(string `$url_path`, array `$query_data = array()`, array `$options = array()`) `\n\nConstruct a PushTask.\n\n#### Parameters\n\n#### Throws\n\n`\\google\\appengine\\api\\taskqueue\\InvalidArgumentException`\n\nif\n\n- A supplied argument is not the correct type.\n- Any of the specified options are invalid.\n- The header 'content-type' is specified.\n- Any supplied headers are not of the format 'key:value'.\n\n### getUrl\n\n`getUrl() : string`\n\nReturn the task's URL. This will be the task's URL path, plus any query\nparameters if the task's method is GET, HEAD, or DELETE.\n\n#### Returns\n\n`string`\n\nThe task's URL path.\n\n### getQueryData\n\n`getQueryData() : array`\n\nReturn the task's query data.\n\n#### Returns\n\n`array`\n\nThe task's query data.\n\n### getName\n\n`getName() : string`\n\nReturn the task's name if it was explicitly named.\n\n#### Returns\n\n`string`\n\nThe task's name if it was explicity named, or empty string\nif it will be given a uniquely generated name in the queue.\n\n### getDelaySeconds\n\n`getDelaySeconds() : float`\n\nReturn the task's execution delay, in seconds.\n\n#### Returns\n\n`float`\n\nThe task's execution delay in seconds.\n\n### getMethod\n\n`getMethod() : string`\n\nReturn the task's HTTP method.\n\n#### Returns\n\n`string`\n\nThe task's HTTP method: 'DELETE', 'GET', 'HEAD',\n'POST', or 'PUT'.\n\n### getHeaders\n\n`getHeaders() : array\u003cmixed,string\u003e`\n\nReturn the task's headers.\n\n#### Returns\n\n`array\u003cmixed,string\u003e`\n\nThe headers that will be sent when the task is\nexecuted. This list is not exhaustive as the backend may add more\nheaders at execution time.\nThe array is numerically indexed and of the same format as that returned\nby the standard headers_list() function.\n\n### add\n\n`add( `$queue_name = 'default'`) : string`\n\nAdds the task to a queue.\n\n#### Parameters\n\n#### Throws\n\n`\\google\\appengine\\api\\taskqueue\\TaskAlreadyExistsException`\n\nif a task of the same name already\nexists in the queue.\n\n`\\google\\appengine\\api\\taskqueue\\TaskQueueException`\n\nif there was a problem using the service.\n\n#### Returns\n\n`string`\n\nThe name of the task."]]