PHP 5 ha raggiunto la fine del supporto e verrà
ritirato
il 31 gennaio 2026. Dopo il ritiro, non potrai eseguire il deployment di applicazioni PHP 5, anche se la tua organizzazione ha utilizzato in precedenza un criterio dell'organizzazione per riattivare i deployment di runtime legacy. Le tue applicazioni PHP
5 esistenti continueranno a essere eseguite e a ricevere traffico dopo la
data di ritiro. Ti consigliamo di eseguire la migrazione all'ultima versione supportata di PHP.
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
ID regione
Il REGION_ID è un codice abbreviato che Google assegna
in base alla regione selezionata durante la creazione dell'app. Il codice non
corrisponde a un paese o a una provincia, anche se alcuni ID regione possono sembrare
simili ai codici di paesi e province di uso comune. Per le app create dopo
febbraio 2020, REGION_ID.r è incluso negli
URL App Engine. Per le app esistenti create prima di questa data, l'ID regione è facoltativo nell'URL.
Questa pagina descrive come inviare richieste HTTP(S) dalla tua app App Engine.
App Engine utilizza il servizio di recupero URL per inviare richieste HTTP(S) in uscita.
Per informazioni dettagliate sui limiti di dimensione delle richieste e sulle intestazioni inviate in una richiesta di recupero URL, consulta Richieste in uscita.
Emettere una richiesta HTTP
Il linguaggio PHP fornisce diverse funzioni per effettuare richieste HTTP remote.
Questi vengono implementati in modi diversi in Google App Engine e sono soggetti a quote e costi diversi:
Gestori di stream: i gestori di stream PHP nativi http:// e https:// sono configurati per utilizzare il servizio URL Fetch di App Engine per effettuare richieste HTTP. Molte funzioni PHP, come
file_get_contents(),
utilizzano indirettamente i gestori di stream e quindi anche il servizio URL Fetch.
cURL "lite": cURL "lite" è una versione della libreria cURL fornita da Google
che utilizza il
servizio URL Fetch anziché
il servizio Sockets. Devi attivare cURL "lite" nel
file php.ini della tua applicazione.
I seguenti metodi dell'estensione cURL non sono supportati:
curl_multi_* funzioni
supporto per protocolli non standard
supporto di porte diverse da 80 (HTTP) o 443 (HTTPS)
La scelta tra cURL, cURL Lite o stream wrapper dipende in gran parte
dalla tua applicazione e dalle tue preferenze. In caso di dubbi, utilizza la
libreria HTTP Guzzle. Guzzle
fornisce un livello di astrazione per le richieste HTTP, che ti consente di modificare
il servizio sottostante senza riscrivere il codice dell'applicazione.
Gestori di stream
I gestori di stream HTTP(S) standard vengono utilizzati nelle funzioni PHP integrate, come fopen() e file_get_contents().
Attiva cURL o cURL "lite" in php.ini per utilizzare le funzioni cURL per le richieste
in uscita. cURL "lite" utilizza il servizio URL Fetch,
mentre cURL utilizza l'API Sockets
Per impostazione predefinita, Guzzle utilizza l'handler di stream di PHP, ma utilizzerà automaticamente un
handler cURL se cURL o cURL "lite" è abilitato.
Utilizza l'opzione timeout in
Contesto HTTP per modificare
la scadenza.
Disattivare i reindirizzamenti
Se utilizzi URL Fetch, il servizio URL Fetch sottostante segue fino a cinque
reindirizzamenti per impostazione predefinita. Questi reindirizzamenti potrebbero inoltrare informazioni sensibili, come
le intestazioni di autorizzazione, alla destinazione reindirizzata. Se la tua app non
richiede reindirizzamenti HTTP, ti consigliamo di disattivarli.
Per indicare al servizio URL Fetch di non seguire i reindirizzamenti, la tua app deve
impostare il parametro follow_location nelle
opzioni di contesto HTTP
su false.
Emettere una richiesta HTTPS
Per impostazione predefinita, il servizio URL Fetch sottostante convalida il certificato
dell'host che contatta e rifiuta le richieste se il certificato
non corrisponde. Non è necessario proteggere esplicitamente la richiesta.
Disattiva la convalida del certificato host
Per impostazione predefinita, l'implementazione di App Engine del wrapper HTTPS tenta di convalidare il certificato dell'host e rifiuta le richieste in cui il certificato non corrisponde. Per disattivare questo comportamento, imposta il valore di
verify_peer su false nelle
opzioni di contesto SSL/TLS.
Emettere una richiesta a un'altra app App Engine
Quando invii una richiesta a un'altra app App Engine, la tua app App Engine
deve affermare la propria identità aggiungendo l'intestazione X-Appengine-Inbound-Appid
alla richiesta.
Se istruisci il servizio URL Fetch a non seguire i reindirizzamenti, App Engine
aggiungerà automaticamente questa intestazione alle richieste.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 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)."]]