Version: 2022.3
言語: 日本語
public static Networking.UnityWebRequest PostWwwForm (string uri, string form);
public static Networking.UnityWebRequest PostWwwForm (Uri uri, string form);

パラメーター

uri フォームデータが送信されるターゲット URI
form An HTML form to send.

戻り値

UnityWebRequest UnityWebRequest は POST を介して uri にフォームデータを送信するように設定します。

説明

Creates a UnityWebRequest configured to send form data to a server via HTTP POST.

This method creates a UnityWebRequest, sets the uri and sets the method to POST. The Content-Type header will be set to application/x-www-form-urlencoded by default.

このメソッドは DownloadHandlerBufferUnityWebRequest にアタッチします。これは利便性のためにほとんどのユーザーが特に REST API のケースでサーバーからの応答を確認するために DownloadHandler を使うことを予想しています。

The string in the form parameter is expected to be a preformatted HTML form. It will be escaped and sent as UTF-8 string.

using UnityEngine;
using UnityEngine.Networking;
using System.Collections;

public class MyBehavior : MonoBehaviour { void Start() { StartCoroutine(Upload()); }

IEnumerator Upload() { using (UnityWebRequest www = UnityWebRequest.PostWwwForm("https://www.my-server.com/myapi", "field1=1&field2=value2")) { yield return www.SendWebRequest();

if (www.result != UnityWebRequest.Result.Success) { Debug.Log(www.error); } else { Debug.Log("Form upload complete!"); } } } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961