2016-08-28 7 views
-2

は、私はこの$jsonDataを取得するためにWEBAPIを使用して、このwebAPIを使用してC#でphp jsonデータを取得するには?

(...../check/checkdata?data=' . $jsonData). 

ように私のURLの末尾にこの$jsonDataを追加したいパラメータ

$jsonData = json_encode(array('shenase'=>$shenase,'fullname'=>$name,'nikokarhaghighi'=>$nikokarhaghighi,'nikokarhoghoghi'=>$nikokarhoghoghi, 
'stateone'=>$stateone,'questionone'=>$questionone,'questiontwo'=>$questiontwo, 
'statethree'=>$statethree,'stateFour'=>$stateFour,'statefive'=>$statefive)); 

としての私のデータを送信するために、このPHPコードを使用しています。このデータをC#でどのように取得できますか?

答えて

1

これには2通りの方法があります。 1つは、PHPコードによって送信されるデータのモデルを作成することです。すなわち

class Model 
{ 
public string shenase{get; set;} 
public string fullname{get; set;} 
// rest of the properties 
} 

あなたはC#のWeb API

public HttpResponseMessage YourEndPoint([FromUri]Model model) 
{ 
//this will atuomatically bind values sent in URL to model 
} 

OtherwayはあなたのC#WebAPIのだけではなく、すなわち

public HttpResponseMessage YourEndPoint(string fullname, string shenase, ...) 
{ 
//this will atuomatically bind values sent in URL to model 
} 

詳細についてはWEB API model bindingをご覧ください対応するパラメータを作成するモデルを作成するのです。

関連する問題