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.
Stay organized with collections
Save and categorize content based on your preferences.
Region ID
The REGION_ID is an abbreviated code that Google assigns
based on the region you select when you create your app. The code does not
correspond to a country or province, even though some region IDs may appear
similar to commonly used country and province codes. For apps created after
February 2020, REGION_ID.r is included in
App Engine URLs. For existing apps created before this date, the
region ID is optional in the URL.
This page describes how to issue HTTP(S) requests from your App Engine
app.
App Engine uses the URL Fetch service to issue outbound HTTP(S) requests.
For details on request size limits and which headers are sent in a URL Fetch
request, see Outbound Requests.
Issue an HTTP request
The PHP language provides several functions for making remote HTTP requests.
These are implemented in different ways in Google App Engine, and are subject to
different quotas and costs:
Stream handlers: The native http:// and https:// PHP stream handlers
are configured to use App Engine's
URL Fetch service to make HTTP
requests. Many PHP functions such as
file_get_contents()
use stream handlers indirectly, and thus also use the URL Fetch service.
cURL "lite": cURL "lite" is a Google-supplied version of the cURL library
that uses the
URL Fetch service instead of
the Sockets service. You must enable cURL "lite" in your application's
php.ini file.
The following methods of the cURL extension are not supported:
curl_multi_* functions
support for non-standard protocols
support for ports other than 80 (HTTP) or 443 (HTTPS)
Deciding whether to use cURL, cURL Lite, or stream wrappers depends largely on
your application and preference. If you are unsure, use the
Guzzle HTTP library. Guzzle
provides an abstraction layer for HTTP requests, which allows you to change
the underlying service without rewriting application code.
Stream handlers
The standard HTTP(S) stream handlers are used in built-in PHP
functions such as fopen() and file_get_contents().
Enable cURL or cURL "lite" in php.ini to use cURL functions for outbound
requests. cURL "lite" uses the URL Fetch service,
while cURL uses the Sockets API
Use the timeout option in
HTTP context to alter
the deadline.
Disable redirects
If you are using URL Fetch, the underlying URL Fetch service follows up to five
redirects by default. These redirects could forward sensitive information, such
as authorization headers, to the redirected destination. If your app does not
require HTTP redirects, it is recommended that you disable the redirects.
To instruct the URL Fetch service to not follow redirects, your app must
set the follow_location parameter in the
HTTP context options
to false.
Issue an HTTPS request
By default, the underlying URL Fetch service validates the certificate
of the host it contacts, and rejects requests if the certificate
doesn't match. You don't need to explicitly secure your request.
Disable host certificate validation
By default, the App Engine implementation of the HTTPS wrapper attempts
to validate the certificate of the host, and rejects requests where the
certificate does not match. To disable this behavior, set the value of
verify_peer to false in the
SSL/TLS context options.
Issue a request to another App Engine app
When issuing a request to another App Engine app, your App Engine app
must assert its identity by adding the header X-Appengine-Inbound-Appid
to the request.
If you instruct the URL Fetch service to not follow redirects, App Engine
will add this header to requests automatically.
[[["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-08-29 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eREGION_ID\u003c/code\u003e is a Google-assigned code based on the region selected during app creation, included in App Engine URLs for apps created after February 2020, but it does not directly correspond to specific countries or provinces.\u003c/p\u003e\n"],["\u003cp\u003eApp Engine uses the URL Fetch service to handle outbound HTTP(S) requests, and PHP offers stream handlers, the cURL extension, and cURL "lite" for making these requests, each with different implementations and associated quotas.\u003c/p\u003e\n"],["\u003cp\u003eStream handlers use the URL Fetch service, the cURL extension uses the Sockets service (requiring billing to be enabled), and cURL "lite" is a Google-supplied version of the cURL library that also uses the URL Fetch service, and certain functions are unsupported.\u003c/p\u003e\n"],["\u003cp\u003eGuzzle HTTP library is recommended as it provides an abstraction layer for HTTP requests, enabling switching between services without code rewrites, and it uses stream handlers or cURL handlers based on availability.\u003c/p\u003e\n"],["\u003cp\u003eDisabling redirects is recommended for enhanced security, and if an app sends requests to another App Engine app, it must include the \u003ccode\u003eX-Appengine-Inbound-Appid\u003c/code\u003e header to assert its identity.\u003c/p\u003e\n"]]],[],null,["Region ID\n\nThe \u003cvar translate=\"no\"\u003eREGION_ID\u003c/var\u003e is an abbreviated code that Google assigns\nbased on the region you select when you create your app. The code does not\ncorrespond to a country or province, even though some region IDs may appear\nsimilar to commonly used country and province codes. For apps created after\nFebruary 2020, \u003cvar translate=\"no\"\u003eREGION_ID\u003c/var\u003e`.r` is included in\nApp Engine URLs. For existing apps created before this date, the\nregion ID is optional in the URL.\n\nLearn more\n[about region IDs](/appengine/docs/legacy/standard/php/how-requests-are-routed#region-id). \nOK\n\nThis page describes how to issue HTTP(S) requests from your App Engine\napp.\n| This API is supported for first-generation runtimes and can be used when [upgrading to corresponding second-generation runtimes](/appengine/docs/standard/\n| php-gen2\n|\n| /services/access). If you are updating to the App Engine PHP 7/8 runtime, refer to the [migration guide](/appengine/migration-center/standard/migrate-to-second-gen/php-differences) to learn about your migration options for legacy bundled services.\nApp Engine uses the URL Fetch service to issue outbound HTTP(S) requests. For details on request size limits and which headers are sent in a URL Fetch request, see [Outbound Requests](/appengine/docs/legacy/standard/php/outbound-requests).\n\nIssue an HTTP request\n\nThe PHP language provides several functions for making remote HTTP requests.\nThese are implemented in different ways in Google App Engine, and are subject to\ndifferent quotas and costs:\n\n- **Stream handlers** : The native `http://` and `https://` PHP stream handlers are configured to use App Engine's [URL Fetch service](/appengine/docs/legacy/standard/php/issue-requests) to make HTTP requests. Many PHP functions such as [file_get_contents()](http://php.net/manual/en/function.file-get-contents.php) use stream handlers indirectly, and thus also use the URL Fetch service.\n- **cURL extension** : The [cURL\n extension](http://php.net/manual/en/book.curl.php) uses the [Sockets service](/appengine/docs/legacy/standard/php/sockets). The cURL extension [must be enabled](/appengine/docs/legacy/standard/php/runtime#dynamically_loadable_extensions) in your application's [php.ini file](/appengine/docs/legacy/standard/php/config/php_ini) and billing must be enabled for your project.\n- **cURL \"lite\"** : cURL \"lite\" is a Google-supplied version of the cURL library that uses the [URL Fetch service](/appengine/docs/legacy/standard/php/issue-requests) instead of the Sockets service. You must enable cURL \"lite\" in your application's [php.ini file](/appengine/docs/legacy/standard/php/config/php_ini#GAE_directives). The following methods of the cURL extension are not supported:\n - `curl_multi_*` functions\n - support for non-standard protocols\n - support for ports other than 80 (HTTP) or 443 (HTTPS)\n\nDeciding whether to use cURL, cURL Lite, or stream wrappers depends largely on\nyour application and preference. If you are unsure, use the\n[Guzzle HTTP library](http://docs.guzzlephp.org/en/latest/index.html). Guzzle\nprovides an abstraction layer for HTTP requests, which allows you to change\nthe underlying service without rewriting application code. \n\nStream handlers\n\nThe standard HTTP(S) stream handlers are used in built-in PHP\nfunctions such as `fopen()` and `file_get_contents()`.\n\n\n $url = 'http://httpbin.org/post?query=update';\n $data = [\u003e'data' = &\u003e#39;this', 'data2' = 'that'];\n $headers = \"accept: */*\\r\\n\" .\n \"Content-Type: application/x-www-form-urlencoded\\r\\n\" .\n \"Custom-Header: custom-value\\r\\n\" .\n \u003e \"Custom-Heade\u003er-Two: custom-value-2\\r\\n&q\u003euot;;\n\n $context = [\n 'h\u003ettp' = [\n 'method' = 'POST',\n 'header' = $headers,\n 'content' = http_build_query($data),\n ]\n ];\n $context = stream_context_create($context);\n $result = file_get_contents($url, false, $context);\n\ncURL and cURL \"lite\"\n\n\nEnable cURL or cURL \"lite\" in php.ini to use cURL functions for outbound\nrequests. cURL \"lite\" uses the [URL Fetch service](/appengine/docs/legacy/standard/php/issue-requests),\nwhile cURL uses the [Sockets API](/appengine/docs/legacy/standard/php/sockets) \n\n $url = 'http://httpbin.org/post?query=update';\n $data = [\u003e'data' = &\u003e#39;this', 'data2' = 'that'];\n $headers = [\n 'Accept: */*',\n 'Content-Type: application/x-www-form-urlencoded',\n 'Custom-Header: custom-value',\n 'Custom-Header-Two: custom-value-2'\n ];\n\n // open connectio\u003en\n $ch = curl_init();\n\n // \u003eset curl options\n $options = [\n CURLO\u003ePT_URL = $url,\n CURLOPT_POST = count($data),\n \u003e CURLOPT_POSTFIELDS = http_build_query\u003e($data),\n CURLOPT_HTTPHEADER = $headers,\n CURLOPT_RETURNTRANSFER = true,\n ];\n curl_setopt_array($ch, $options);\n\n // execute\n $result = curl_exec($ch);\n\n // close connection\n curl_close($ch);\n\nGuzzle\n\nBy default, Guzzle uses PHP's stream handler, but will automatically use a\ncURL handler if cURL or cURL \"lite\" is enabled. \n\n $url = 'http://httpbin.org/post?query=update';\n $data = [\u003e'data' = &\u003e#39;this', 'data2' = '\u003e;that'];\n $headers = [\n \u003e 'Accept' = '*/*',\n 'Content-Type\u003e39; = 'application/x-www-form-urlencod\u003eed',\n 'Custom-Header' = 'custom-value',\n 'Custom-Header-Two' = 'custom-value',\n ];\n\n $guzzle = new GuzzleHttp\\Client;\n $re\u003equest = new GuzzleHttp\\Psr7\\Request('POST', $url, $headers, http_build_query($data));\n $result = $guzzle-send($request);\n\nSet a request timeout\n\nUse the `timeout` option in\n[HTTP context](https://php.net/manual/en/context.http.php) to alter\nthe deadline.\n\nDisable redirects **Important:** To improve the security of your app, it is recommended that you disable redirects.\n\nIf you are using URL Fetch, the underlying URL Fetch service follows up to five\nredirects by default. These redirects could forward sensitive information, such\nas authorization headers, to the redirected destination. If your app does not\nrequire HTTP redirects, it is recommended that you disable the redirects.\n\nTo instruct the URL Fetch service to not follow redirects, your app must\nset the `follow_location` parameter in the\n[HTTP context options](https://php.net/manual/en/context.http.php)\nto `false`.\n\nIssue an HTTPS request\n\nBy default, the underlying URL Fetch service validates the certificate\nof the host it contacts, and rejects requests if the certificate\ndoesn't match. You don't need to explicitly secure your request.\n\nDisable host certificate validation\n\nBy default, the App Engine implementation of the HTTPS wrapper attempts\nto validate the certificate of the host, and rejects requests where the\ncertificate does not match. To disable this behavior, set the value of\n`verify_peer` to `false` in the\n[SSL/TLS context options](https://php.net/manual/en/context.ssl.php).\n| **Note:** The URL Fetch service ignores all other SSL/TLS context options.\n\nIssue a request to another App Engine app\n\nWhen issuing a request to another App Engine app, your App Engine app\nmust assert its identity by adding the header `X-Appengine-Inbound-Appid`\nto the request.\nIf you instruct the URL Fetch service to not follow redirects, App Engine\nwill add this header to requests automatically.\n\nSee [Disabling redirects](#disabling_redirects) for guidance on disabling\nredirects.\n| **Note:** If you are making requests to another App Engine application, use its \u003cvar translate=\"no\"\u003e\u003ca href=\"#appengine-urls\" style=\"border-bottom: 1px dotted #999\" class=\"devsite-dialog-button\" data-modal-dialog-id=\"regional_url\" track-type=\"progressiveHelp\" track-name=\"modalHelp\" track-metadata-goal=\"regionalURL\"\u003eREGION_ID\u003c/a\u003e\u003c/var\u003e`.r.appspot.com` domain name rather than a custom domain for your app.\n\nWhat's next\n\nLearn about the URL Fetch service, such as the headers that are\nsent in a URL Fetch request in [Outbound Requests](/appengine/docs/legacy/standard/php/outbound-requests)."]]