0
function w_getLesVisites($idVisiteur)
{
return json_encode($pdo->getLesVisiteur($idVisiteur));
}
以下Web服務在我Xamarin形式PCL的項目,我有以下RestService類,目的是消耗phpwebservice和我的MySQL本地檢索數據數據庫
public class RestService
{
HttpClient client;
public List<Visite> L_Visites { get; private set; }
public RestService()
{
client = new HttpClient();
client.MaxResponseContentBufferSize = 25600;
}
public async Task<List<Visite>> RefreshDataAsync()
{
string restUrl = "localhost/ppe3JoJuAd/gsbAppliFraisV2/w_visite";
var uri = new Uri(string.Format(restUrl, string.Empty));
try
{
var response = await client.GetAsync(uri);
if(response.IsSuccessStatusCode)
{
var content = await response.Content.ReadAsStringAsync();
L_Visites = JsonConvert.DeserializeObject<List<Visite>>(content);
}
}
catch (Exception ex)
{
Debug.WriteLine(@"ERROR {0}", ex.Message);
}
return L_Visites;
}
}
我的問題是:我怎麼能調用PHP Web服務與一個ID,以便它如預期返回一個JSON值?
在REST API中,通常只需將該ID附加到URL上,如「/ w_visite/7」,但它可能因實現服務的方式而異。 – Jason