在我的应用程序中,C# 应用程序向 PHP 服务器发送请求。该应用程序通过 POST 发送作者名称的详细信息。我希望 PHP 应用程序查询数据库并返回作者详细信息的数组。
我可以成功获取细节信息。接下来,我该如何将数据放入一个数组中,以便发送回C#?
基本上...我怎样才能让PHP数组在C#中正常工作?
String result = "";
string url = LINK_TO_SITE;
using (WebClient client = new WebClient())
{
NameValueCollection postData = new NameValueCollection()
{
{"Author", Properties.Settings.Default.Author}
};
result = Encoding.UTF8.GetString(client.UploadValues(url, postData));
MessageBox.Show(result);
php
$author=$_POST["author"];
$stmt = $mysqli->stmt_init();
$stmt = $mysqli->prepare("SELECT name, date, code FROM Collab where Members=?");
$stmt->bind_param('s', $author);
$stmt->execute();
$stmt->bind_result($name,$date, $code);
我可以成功获取细节信息。接下来,我该如何将数据放入一个数组中,以便发送回C#?
基本上...我怎样才能让PHP数组在C#中正常工作?
json_encode
对数组进行编码,然后使用 #c 中的 JSON 解析器类将 JSON 解析为数组。 - Dom