gpt4 book ai didi

php - 使用 flutter-inappwebview 发送数据到网页

转载 作者:行者123 更新时间:2023-12-05 06:54:00 50 4
gpt4 key购买 nike

我正在使用 inappwebview 包,它会打开一个网页。我想从我的 Flutter 应用程序接收一些数据到我的网页 (php/html) 或者可能有更好的选择?基本上用户在应用程序中选择一个产品,然后 inappwebview 包将打开此网页以显示一些特定产品)。
我发现 inappwebview postData: "Loads the given [url] with [postData] using POST method into this WebView"我试过的是;

    controller.postUrl(
url: "web link",
postData: utf8.encode(data)
);

而在网页(php)中我不知道这些数据是如何接收的,我试着这样写;

$data =utf8_decode($_POST['postData']);

我猜这是不正确的。请帮助我!

最佳答案

postData 参数表示 HTTP POST 请求的主体。

一个使用最新版本 5.0.5+3flutter_inappwebview 的简单示例插件是:

var postData = Uint8List.fromList(utf8.encode("firstname=Foo&lastname=Bar"));
controller.postUrl(url: Uri.parse("https://example.com/my-post-endpoint"), postData: postData);

postDatax-www-form-urlencoded 格式的请求主体。

因此,在您的 PHP 服务器中,您可以像往常一样访问 firstnamelastname 值,即 $_POST['firstname'] $_POST['lastname']

关于php - 使用 flutter-inappwebview 发送数据到网页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65655530/

50 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com