PHP 5 telah mencapai akhir dukungan dan akan
dihentikan penggunaannya
pada 31 Januari 2026. Setelah penghentian penggunaan, Anda tidak akan dapat men-deploy aplikasi PHP 5, meskipun organisasi Anda sebelumnya menggunakan kebijakan organisasi untuk mengaktifkan kembali deployment runtime lama. Aplikasi PHP 5 yang sudah ada akan terus berjalan dan menerima traffic setelah
tanggal penghentiannya. Sebaiknya Anda bermigrasi ke versi PHP terbaru yang didukung.
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
ID region
REGION_ID adalah kode singkat yang ditetapkan Google berdasarkan region yang Anda pilih saat membuat aplikasi. Kode ini tidak sesuai dengan negara atau provinsi, meskipun beberapa ID region mungkin tampak mirip dengan kode negara dan provinsi yang umum digunakan. Untuk aplikasi yang dibuat setelah Februari 2020, REGION_ID.r disertakan dalam URL App Engine. Untuk aplikasi lama yang dibuat sebelum tanggal tersebut, ID region bersifat opsional dalam URL.
Halaman ini menjelaskan cara menerbitkan permintaan HTTP(S) dari aplikasi App Engine Anda.
App Engine menggunakan layanan URL-Fetch untuk menerbitkan permintaan HTTP(S) keluar.
Untuk mengetahui detail tentang batas ukuran permintaan dan header mana yang dikirim pada permintaan URL Fetch, lihat Permintaan Keluar.
Mengirim permintaan HTTP
Bahasa PHP menyediakan beberapa fungsi untuk membuat permintaan HTTP jarak jauh.
Tindakan ini diterapkan dengan berbagai cara di Google App Engine, dan bergantung pada kuota dan biaya yang berbeda:
Pengendali stream: http:// native dan pada pengendali stream PHP https:// dikonfigurasi untuk menggunakan Layanan URL-Fetch App Engine untuk membuat permintaan HTTP. Banyak fungsi PHP seperti file_get_contents() menggunakan pengendali stream secara tidak langsung, sehingga juga menggunakan layanan URL-Fetch.
cURL "lite": cURL "lite" adalah versi library cURL yang disediakan Google yang menggunakan layanan URL-Fetch, bukan layanan Sockets. Anda harus mengaktifkan cURL "lite" di file php.ini aplikasi Anda.
Metode ekstensi cURL berikut tidak didukung:
fungsi curl_multi_*
dukungan untuk protokol non-standar
dukungan untuk port selain 80 (HTTP) atau 443 (HTTPS)
Menentukan apakah akan menggunakan cURL, cURL Lite, atau wrapper stream sangat bergantung pada aplikasi dan preferensi Anda. Jika Anda tidak yakin, gunakan library HTTP Guzzle. Guzzle menyediakan lapisan abstraksi untuk permintaan HTTP, sehingga Anda dapat mengubah layanan dasar tanpa menulis ulang kode aplikasi.
Pengendali stream
Pengendali stream HTTP(S) standar digunakan dalam fungsi PHP bawaan seperti fopen() dan file_get_contents().
Aktifkan cURL atau cURL "lite" di php.ini untuk menggunakan fungsi cURL untuk permintaan keluar. cURL "lite" menggunakan layanan URL-Fetch, sedangkan cURL menggunakan Sockets API
Gunakan opsi timeout dalam konteks HTTP untuk mengubah batas waktu.
Menonaktifkan pengalihan
Jika Anda menggunakan URL Fetch, layanan URL-Fetch dasar akan mengikuti hingga lima pengalihan secara default. Pengalihan ini dapat meneruskan informasi sensitif, seperti header otorisasi, ke tujuan yang dialihkan. Jika aplikasi Anda tidak
memerlukan pengalihan HTTP, sebaiknya nonaktifkan pengalihan.
Untuk menginstruksikan layanan URL-Fetch agar tidak mengikuti pengalihan, aplikasi Anda harus menetapkan parameter follow_location di opsi konteks HTTP ke false.
Mengirim permintaan HTTPS
Secara default, layanan Fetch URL yang mendasarinya memvalidasi sertifikat host yang dihubungi, dan menolak permintaan jika sertifikat tidak cocok. Anda tidak perlu mengamankan permintaan secara eksplisit.
Menonaktifkan validasi sertifikat host
Secara default, penerapan App Engine wrapper HTTPS mencoba memvalidasi sertifikat host, dan menolak permintaan yang sertifikatnya tidak cocok. Untuk menonaktifkan perilaku ini, tetapkan nilai verify_peer ke false di opsi konteks SSL/TLS.
Mengirim permintaan ke aplikasi App Engine lain
Saat menerbitkan permintaan ke aplikasi App Engine lain, aplikasi App Engine Anda harus menegaskan identitasnya dengan menambahkan header X-Appengine-Inbound-Appid ke permintaan tersebut.
Jika Anda menginstruksikan layanan URL-Fetch untuk tidak mengikuti pengalihan, App Engine akan otomatis menambahkan header ini ke permintaan.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-19 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,["# Issuing HTTP(S) Requests\n\n### 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---------------------\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\n### Stream 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 = ['data' =\u003e 'this', 'data2' =\u003e 'that'];\n $headers = \"accept: */*\\r\\n\" .\n \"Content-Type: application/x-www-form-urlencoded\\r\\n\" .\n \"Custom-Header: custom-value\\r\\n\" .\n \"Custom-Header-Two: custom-value-2\\r\\n\";\n\n $context = [\n 'http' =\u003e [\n 'method' =\u003e 'POST',\n 'header' =\u003e $headers,\n 'content' =\u003e http_build_query($data),\n ]\n ];\n $context = stream_context_create($context);\n $result = file_get_contents($url, false, $context);\n\n### cURL 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 = ['data' =\u003e 'this', 'data2' =\u003e '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 connection\n $ch = curl_init();\n\n // set curl options\n $options = [\n CURLOPT_URL =\u003e $url,\n CURLOPT_POST =\u003e count($data),\n CURLOPT_POSTFIELDS =\u003e http_build_query($data),\n CURLOPT_HTTPHEADER =\u003e $headers,\n CURLOPT_RETURNTRANSFER =\u003e 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\n### Guzzle\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 = ['data' =\u003e 'this', 'data2' =\u003e 'that'];\n $headers = [\n 'Accept' =\u003e '*/*',\n 'Content-Type' =\u003e 'application/x-www-form-urlencoded',\n 'Custom-Header' =\u003e 'custom-value',\n 'Custom-Header-Two' =\u003e 'custom-value',\n ];\n\n $guzzle = new GuzzleHttp\\Client;\n $request = new GuzzleHttp\\Psr7\\Request('POST', $url, $headers, http_build_query($data));\n $result = $guzzle-\u003esend($request);\n\n### Set 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\n### Disable redirects\n\n| **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----------------------\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\n### Disable 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-----------------------------------------\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-----------\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)."]]