2012-03-22 14 views
0

私はexpediaを使用してホテルの予約アプリケーションを開発しています。私はhttppostandroidでhttppostを使用して休憩データを送信する方法

http:/api.ean.com/ean-services/rs/hotel/v3/list?minorRev=[current minorRev #] 
&cid=55505 
&apiKey=xxx-yourOwnKey-xxx 
&customerUserAgent=xxx 
&customerIpAddress=xxx 
&locale=en_US 
&currencyCode=USD 
&city=Seattle 
&stateProvinceCode=WA 
&countryCode=US 
&supplierCacheTolerance=MED 
&arrivalDate=09/04/2012 
&departureDate=09/05/2012 
&room1=2 
&numberOfResults=1 
&supplierCacheTolerance=MED_ENHANCED 
+0

APIは、このコールを処理しているフォーマットはどのようなものです使用してサーバに以下の残りのデータを送信する必要がありますか?それはそれに依存します。本文xml/jsonを期待しているのですか、それともこれらのすべてをURL自体に渡すといいですか? –

+0

はい、これらのXML/JSON/REST形式が必要です。これらのXML/JSON/REST形式を期待しているコード – vinuonline

答えて

2
String urlToSendRequest = "https://example.net"; 
String targetDomain = "example.net"; 

DefaultHttpClient httpClient = new DefaultHttpClient(); 
HttpHost targetHost = new HttpHost(targetDomain, 80, "http"); 

HttpPost httpPost = new HttpPost(urlToSendRequest); 

httpPost.addHeader("Content-Type", "application/xml"); 

StringEntity entity = new StringEntity("<input>test</input>", "UTF-8"); 
entity.setContentType("application/xml"); 
httpPost.setEntity(entity); 

HttpResponse response = httpClient.execute(targetHost, httpPost); 

Reader r = new InputStreamReader(response.getEntity().getContent()); 
+0

を入力してください。いくつかのコードを入力してください – vinuonline

関連する問題