我正在尝试在Windows窗体应用程序中使用用PHP编写的restful webservice(返回JSon响应)。它给出了一些回复的html
此网站需要使用Javascript工作,请在您的浏览器中启用Javascript或使用支持Javascript的浏览器
网络服务
#!/bin/bash
mysql --host=localhost --user=root --password=111111
mysql 1<< EOF
INSERT INTO
table1(id)
SELECT MAX(id) + 1 FROM table1;
EOF
C#代码:点击按钮我发出请求,但意外响应了一些html
//Slim based php webservice
$app->get(
"/books",
function () use ($app) {
$books[0] = array(
"id" => "1",
"name" => "lifeGoesOn" ,
"author" => "nomibhaii"
);
$books[1] = array(
"id" => "2",
"name" => "lifesaysgoodbye" ,
"author" => "nomibhaii"
);
$app->response()->header("Content-Type", "application/json");
return json_encode($books);
}
)
;
我收到此回应回复:
private void button1_Click(object sender, EventArgs e)
{
string response = null;
using (var client = new WebClient())
{
response = client.DownloadString("http://nomi.byethost5.com/api/index.php/books");
if (response != "")
{
resultBox.Text = response;
}
}
}